lib/rails_admin/config/actions.rb in rails_admin-0.5.0 vs lib/rails_admin/config/actions.rb in rails_admin-0.6.0

- old
+ new

@@ -50,16 +50,11 @@ #{parent} true def key :#{key} end }) - a.instance_eval(&block) if block - unless a.custom_key.in?((@@actions || []).map(&:custom_key)) - (@@actions ||= []) << a - else - raise "Action #{a.custom_key} already exist. Please change its custom key" - end + add_action_custom_key(a, &block) end def reset @@actions = nil end @@ -71,16 +66,11 @@ end instance_eval %{ def #{name}(&block) action = #{klass}.new - action.instance_eval &block if block - unless action.custom_key.in?((@@actions || []).map(&:custom_key)) - (@@actions ||= []) << action - else - raise "Action \#{action.custom_key} already exist. Please change its custom key" - end + add_action_custom_key(action, &block) end } end private @@ -97,9 +87,19 @@ BulkDelete.new, HistoryShow.new, HistoryIndex.new, ShowInApp.new, ] + end + + def add_action_custom_key(action, &block) + action.instance_eval(&block) if block + @@actions ||= [] + unless action.custom_key.in?(@@actions.map(&:custom_key)) + @@actions << action + else + raise "Action #{action.custom_key} already exists. Please change its custom key." + end end end end end