Module: Gearhead::Extensions::CustomActions
- Included in:
- Gear
- Defined in:
- lib/gearhead/extensions/custom_actions.rb
Defined Under Namespace
Classes: CustomAction
Class Method Summary collapse
Instance Method Summary collapse
- #collection_action(name, options = {}, &block) ⇒ Object
- #custom_action(type, name, options = {}, &block) ⇒ Object
- #member_action(name, options = {}, &block) ⇒ Object
Class Method Details
.included(klass) ⇒ Object
4 5 6 7 |
# File 'lib/gearhead/extensions/custom_actions.rb', line 4 def self.included(klass) klass.define_gear_setting :collection_actions, {} klass.define_gear_setting :member_actions, {} end |
Instance Method Details
#collection_action(name, options = {}, &block) ⇒ Object
31 32 33 |
# File 'lib/gearhead/extensions/custom_actions.rb', line 31 def collection_action(name, = {}, &block) custom_action(:collection, name, , &block) end |
#custom_action(type, name, options = {}, &block) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/gearhead/extensions/custom_actions.rb', line 18 def custom_action(type, name, = {}, &block) vias = (Array([:via]).presence || [:get]).map { |via| via.downcase.to_sym } if type == :member @_gear_member_actions[name] = CustomAction.new(name, vias, &block) else @_gear_collection_actions[name] = CustomAction.new(name, vias, &block) end end |
#member_action(name, options = {}, &block) ⇒ Object
27 28 29 |
# File 'lib/gearhead/extensions/custom_actions.rb', line 27 def member_action(name, = {}, &block) custom_action(:member, name, , &block) end |