Class: Gearhead::ResourceFinder
- Inherits:
-
Object
- Object
- Gearhead::ResourceFinder
- Defined in:
- lib/gearhead/resource_finder.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(gear, params) ⇒ ResourceFinder
constructor
A new instance of ResourceFinder.
- #resource ⇒ Object
Constructor Details
#initialize(gear, params) ⇒ ResourceFinder
Returns a new instance of ResourceFinder.
7 8 9 10 |
# File 'lib/gearhead/resource_finder.rb', line 7 def initialize(gear, params) @gear = gear @params = params end |
Class Method Details
.for(gear, params) ⇒ Object
3 4 5 |
# File 'lib/gearhead/resource_finder.rb', line 3 def self.for(gear, params) new(gear, params).resource end |
Instance Method Details
#resource ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/gearhead/resource_finder.rb', line 12 def resource if @gear._gear_finder.present? @gear._gear_finder.call(@params) else @gear.resource.find_by(@gear._gear_param_key => @params[:resource_id]) end end |