Class: ExpressAdmin::Commandable
- Inherits:
-
Object
- Object
- ExpressAdmin::Commandable
- Defined in:
- lib/express_admin/commandable.rb
Instance Method Summary collapse
- #call(mapper, options = {}) ⇒ Object
-
#initialize(defaults = {}) ⇒ Commandable
constructor
A new instance of Commandable.
Constructor Details
#initialize(defaults = {}) ⇒ Commandable
Returns a new instance of Commandable.
3 4 5 |
# File 'lib/express_admin/commandable.rb', line 3 def initialize(defaults = {}) @defaults = defaults end |
Instance Method Details
#call(mapper, options = {}) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/express_admin/commandable.rb', line 7 def call(mapper, = {}) = @defaults.merge() controller_name = mapper.send(:parent_resource).controller resource_class = "#{controller_name.classify.pluralize}Controller".constantize.resource_class resource_class.commands.each do |action| # post :foo, to: "module/controller#foo" mapper.member do mapper.post action, to: "#{controller_name}##{action}" end end end |