Class: ActiveScaffold::Routing::Association
- Defined in:
- lib/active_scaffold/extensions/routing_mapper.rb
Direct Known Subclasses
Instance Method Summary collapse
- #call(mapper, options = {}) ⇒ Object
- #default_actions(actions_hash) ⇒ Object
- #get_actions(actions_hash, options) ⇒ Object
Instance Method Details
#call(mapper, options = {}) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/active_scaffold/extensions/routing_mapper.rb', line 28 def call(mapper, = {}) actions = get_actions(ACTIVE_SCAFFOLD_ASSOCIATION_ROUTING, ) mapper.collection do ActiveScaffold::Routing::ACTIVE_SCAFFOLD_ASSOCIATION_ROUTING[:collection].each do |name, type| mapper.match(name, via: type) if actions.include? name end end mapper.member do ActiveScaffold::Routing::ACTIVE_SCAFFOLD_ASSOCIATION_ROUTING[:member].each do |name, type| mapper.match(name, via: type) if actions.include? name end end end |
#default_actions(actions_hash) ⇒ Object
13 14 15 |
# File 'lib/active_scaffold/extensions/routing_mapper.rb', line 13 def default_actions(actions_hash) (actions_hash[:collection].keys + actions_hash[:member].keys).uniq end |
#get_actions(actions_hash, options) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/active_scaffold/extensions/routing_mapper.rb', line 17 def get_actions(actions_hash, ) default_actions = default_actions(actions_hash) if (only = [:only]) Array(only).map(&:to_sym) elsif (except = [:except]) default_actions - Array(except).map(&:to_sym) else default_actions end end |