lib/hungry/site.rb in hungry-0.0.1 vs lib/hungry/site.rb in hungry-0.1.0
- old
+ new
@@ -1,22 +1,36 @@
module Hungry
class Site < Resource
self.endpoint = '/sites'
+ ### FINDERS:
+
+ def self.with_hostname(hostname)
+ collection.all(hostname: hostname).first
+ end
+
+ def self.for_country(country)
+ collection.all(country: country.id).first
+ end
+
+ def self.default_site
+ collection.all(default: true).first
+ end
+
+
### ATTRIBUTES:
### Preview:
attr_accessor :id, :name, :title, :subtitle, :identifier, :default, :locale,
- :url, :timezone, :country, :applications,
+ :url, :email, :support_email, :timezone, :country, :applications,
### Utility:
- :resources, :counters
+ :resources, :counters
- ### FINDERS:
-
- def self.with_hostname(hostname)
- collection.all(hostname: hostname).first
+ def hostname
+ uri = URI.parse(url) rescue nil
+ uri && uri.hostname
end
end
end