Class: Gearhead::GearLookup
- Inherits:
-
Object
- Object
- Gearhead::GearLookup
- Defined in:
- lib/gearhead/gear_lookup.rb
Instance Attribute Summary collapse
-
#request ⇒ Object
readonly
Returns the value of attribute request.
Class Method Summary collapse
Instance Method Summary collapse
-
#gear ⇒ Object
if the resource is already mounted, we don’t want to expose it twice.
-
#initialize(request) ⇒ GearLookup
constructor
A new instance of GearLookup.
Constructor Details
#initialize(request) ⇒ GearLookup
Returns a new instance of GearLookup.
8 9 10 |
# File 'lib/gearhead/gear_lookup.rb', line 8 def initialize(request) @request = request end |
Instance Attribute Details
#request ⇒ Object (readonly)
Returns the value of attribute request.
7 8 9 |
# File 'lib/gearhead/gear_lookup.rb', line 7 def request @request end |
Class Method Details
.for(request) ⇒ Object
3 4 5 |
# File 'lib/gearhead/gear_lookup.rb', line 3 def self.for(request) new(request).gear end |
Instance Method Details
#gear ⇒ Object
if the resource is already mounted, we don’t want to expose it twice. return false return nil if we don’t know the class
14 15 16 17 18 19 20 21 |
# File 'lib/gearhead/gear_lookup.rb', line 14 def gear registered_gear = Gearhead.registry.find(request.params[:resource_class]) return registered_gear if registered_gear return nil if inferred_resource_class.nil? return false if Gearhead.registry.for_resource(inferred_resource_class.name) default_gear end |