lib/hungry/venue.rb in hungry-0.0.1 vs lib/hungry/venue.rb in hungry-0.1.0
- old
+ new
@@ -4,32 +4,18 @@
self.endpoint = '/venues'
### RESOURCES:
- has_many :reviews, Review
+ has_many :reviews, 'Hungry::Review'
- belongs_to :country, Country
+ belongs_to :country, 'Hungry::Country'
- belongs_to :region, Region
+ belongs_to :region, 'Hungry::Region'
- belongs_to :city, City
+ belongs_to :city, 'Hungry::City'
- ### ATTRIBUTES:
-
- ### Preview:
- attr_accessor :id, :name, :category, :telephone, :fax, :website_url,
- :tagline, :rating, :url, :address, :geolocation, :relevance,
- :distance, :plan,
-
- ### Full:
- :reachability, :staff, :prices, :capacity, :description,
- :tags, :menus, :images, :maintainers, :awards, :opening_hours,
-
- ### Utility:
- :resources, :counters, :created_at, :updated_at
-
### FINDERS:
def self.collection
Collection.new(self, endpoint, default_criteria)
end
@@ -48,10 +34,45 @@
def self.sort_by(sortable)
collection.sort_by(sortable)
end
+ def self.maintainable_by(user_or_id)
+ collection.maintainable_by(user_or_id)
+ end
+
def self.paginate(page, options = {})
collection.paginate(page, options)
+ end
+
+ ### ATTRIBUTES:
+
+ ### Preview:
+ attr_accessor :id, :name, :category, :telephone, :fax, :website_url,
+ :tagline, :rating, :url, :address, :geolocation,
+ :currency_symbol, :relevance, :distance, :plan,
+
+ ### Full:
+ :reachability, :staff, :prices, :capacity, :description,
+ :tags, :menus, :images, :maintainers, :awards, :opening_hours,
+ :holidays,
+
+ ### Utility:
+ :counters, :created_at, :updated_at, :status
+
+ lazy_load :tags, :menus, :maintainers, :opening_hours, :holidays
+
+ def geolocation=(new_coordinates)
+ @geolocation = Geolocation.parse(new_coordinates).tap do |geo|
+ attributes[:geolocation] = geo
+ end
+ end
+
+ def menus=(new_menus)
+ @menus = new_menus.map do |attributes|
+ menu = Menu.new(attributes)
+ menu.data_source = data_source
+ menu
+ end
end
end
end