Sha256: 840998557e9a9a75d717eba3d4a41c24276a7a614090c56f42e61708a8fb7f5e

Contents?: true

Size: 784 Bytes

Versions: 2

Compression:

Stored size: 784 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, :emails,

                  ### Utility:
                  :resources, :counters

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

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hungry-0.2.0 lib/hungry/site.rb
hungry-0.1.5 lib/hungry/site.rb