Class: UserPlane::RouteConcerns::AbstractConcern
- Inherits:
-
Object
- Object
- UserPlane::RouteConcerns::AbstractConcern
- Defined in:
- lib/user_plane/route_concerns.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#concern_options ⇒ Object
Returns the value of attribute concern_options.
-
#mapper ⇒ Object
Returns the value of attribute mapper.
Instance Method Summary collapse
-
#call(mapper, concern_options = {}) ⇒ Object
The abstract concern should be able to handle resources having a preferred collection/resource target.
-
#exists?(concern) ⇒ Boolean
Returns true if a particular concern exists.
-
#initialize(options = {}) ⇒ AbstractConcern
constructor
A new instance of AbstractConcern.
- #options(custom_route_options = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ AbstractConcern
Returns a new instance of AbstractConcern.
14 15 16 17 18 |
# File 'lib/user_plane/route_concerns.rb', line 14 def initialize( = {}) defaults = RouteConcerns::DEFAULTS.merge() @namespace = defaults[:namespace] @defaults = defaults.except(:namespace) end |
Instance Attribute Details
#concern_options ⇒ Object
Returns the value of attribute concern_options.
11 12 13 |
# File 'lib/user_plane/route_concerns.rb', line 11 def @concern_options end |
#mapper ⇒ Object
Returns the value of attribute mapper.
12 13 14 |
# File 'lib/user_plane/route_concerns.rb', line 12 def mapper @mapper end |
Instance Method Details
#call(mapper, concern_options = {}) ⇒ Object
The abstract concern should be able to handle resources having a preferred collection/resource target.
27 28 29 30 31 32 |
# File 'lib/user_plane/route_concerns.rb', line 27 def call(mapper, = {}) @mapper = mapper @concern_options = build end |
#exists?(concern) ⇒ Boolean
Returns true if a particular concern exists
21 22 23 |
# File 'lib/user_plane/route_concerns.rb', line 21 def exists? concern mapper.instance_variable_get('@concerns').include?(concern) end |
#options(custom_route_options = {}) ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/user_plane/route_concerns.rb', line 34 def ={} resource_scope = mapper.send :resource_scope? if resource_scope @defaults.merge(@concern_options).merge() else @defaults.merge(@concern_options).merge().except(:on) end end |