module Gearhead::Extensions::CustomActions
Public Class Methods
included(klass)
click to toggle source
# 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
Public Instance Methods
collection_action(name, options = {}, &block)
click to toggle source
# File lib/gearhead/extensions/custom_actions.rb, line 31 def collection_action(name, options = {}, &block) custom_action(:collection, name, options, &block) end
custom_action(type, name, options = {}, &block)
click to toggle source
# File lib/gearhead/extensions/custom_actions.rb, line 18 def custom_action(type, name, options = {}, &block) vias = (Array(options[: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)
click to toggle source
# File lib/gearhead/extensions/custom_actions.rb, line 27 def member_action(name, options = {}, &block) custom_action(:member, name, options, &block) end