Class: QuickTravel::Resource
- Inherits:
-
Adapter
- Object
- Adapter
- QuickTravel::Resource
show all
- Defined in:
- lib/quick_travel/mock.rb,
lib/quick_travel/resource.rb
Defined Under Namespace
Classes: GenerateCacheKey
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Adapter
all, belongs_to, create, has_many, #to_s, update
#define_readers, #initialize, #to_hash
Class Method Details
.all_with_price(opts) ⇒ Object
14
15
16
17
|
# File 'lib/quick_travel/resource.rb', line 14
def self.all_with_price(opts)
cache_key = GenerateCacheKey.new(name, opts).call
find_all!("/api/resources/index_with_price.json", opts.merge(cache_key: cache_key))
end
|
.find(id) ⇒ Object
3
4
5
|
# File 'lib/quick_travel/mock.rb', line 3
def self.find(id)
new(id: id)
end
|
Instance Method Details
#bed_requirements ⇒ Object
32
33
34
35
36
|
# File 'lib/quick_travel/resource.rb', line 32
def bed_requirements
@_bed_requirements ||= Array.wrap(@bed_requirements).map do |bed_requirement|
BedRequirement.new(bed_requirement)
end
end
|
#category ⇒ Object
27
28
29
30
|
# File 'lib/quick_travel/resource.rb', line 27
def category
return nil if @category.nil?
@_category ||= QuickTravel::ResourceCategory.new(@category)
end
|
#locations ⇒ Object
23
24
25
|
# File 'lib/quick_travel/resource.rb', line 23
def locations
location_ids.map{ |id| Location.find(id) }
end
|
#sub_resources ⇒ Object
10
11
12
|
# File 'lib/quick_travel/resource.rb', line 10
def sub_resources
Resource.find_all!('/api/resources.json', parent_resource_id: @id)
end
|