Module: LoadResources::ClassMethods
- Defined in:
- lib/load_resources.rb
Instance Method Summary collapse
- #automatic_resource(resource_name, actions = nil, class_name = nil) ⇒ Object
- #collection_resource_callback(resource_name, actions) ⇒ Object
- #new_resource_callback(resource_name, actions) ⇒ Object
- #single_resource_callback(resource_name, actions) ⇒ Object
Instance Method Details
#automatic_resource(resource_name, actions = nil, class_name = nil) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/load_resources.rb', line 12 def automatic_resource(resource_name, actions = nil, class_name = nil) actions ||= default_actions new_resource_callback(resource_name, actions) collection_resource_callback(resource_name, actions) single_resource_callback(resource_name, actions) end |
#collection_resource_callback(resource_name, actions) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/load_resources.rb', line 19 def collection_resource_callback(resource_name, actions) collection_actions = (actions & collection_resource_actions) if collection_actions.present? before_action(only: collection_actions) do load_resources(resource_name) end end end |
#new_resource_callback(resource_name, actions) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/load_resources.rb', line 28 def new_resource_callback(resource_name, actions) new_instance_actions = (actions & new_resource_actions) if new_instance_actions.present? before_action(only: new_instance_actions) do new_resource(resource_name) end end end |
#single_resource_callback(resource_name, actions) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/load_resources.rb', line 37 def single_resource_callback(resource_name, actions) single_actions = (actions & single_resource_actions) if single_actions.present? before_action(only: single_actions) do load_resource(resource_name) end end end |