little improvements for active_model

35 views
Skip to first unread message

Dmitry Gautsel

unread,
Apr 18, 2016, 3:45:40 PM4/18/16
to Ruby on Rails: Core
Hi all.

What do you think about little improvements listed below?

before:
{ error: message }.merge(options.except(*CALLBACKS_OPTIONS + MESSAGE_OPTIONS))
after:
{ error: message }.merge!(options.except(*CALLBACKS_OPTIONS + MESSAGE_OPTIONS))


before:
matchers.map { |method| method.match(method_name) }.compact
after:
matchers.map! { |method| method.match(method_name) }.tap(&:compact!)


before:
attribute_aliases.merge(new_name.to_s => old_name.to_s)
after:
{new_name.to_s => old_name.to_s}.reverse_merge!(attribute_aliases)


I just started to dive into the Ruby on Rails. And maybe it's not good idea to make this improvements. But if it's OK, I would continue to improve somethign like that.

Regards, Dmitry
 
 
Reply all
Reply to author
Forward
0 new messages