Sha256: e5c80ffbed694da81b64a472ab3e1d31dc95f7b0df7571aa07d7a4f356dc4bcc

Contents?: true

Size: 775 Bytes

Versions: 3

Compression:

Stored size: 775 Bytes

Contents

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, :email, :support_email, :timezone, :country,
                  :newsletter_list, :applications,

                  ### Utility:
                  :resources, :counters

    def hostname
      uri = URI.parse(url) rescue nil
      uri && uri.hostname
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hungry-0.1.4 lib/hungry/site.rb
hungry-0.1.3 lib/hungry/site.rb
hungry-0.1.2 lib/hungry/site.rb