Sha256: a17079ae74e3a0975df3eb7d902ab232067f02f9587bd0b8ecfa8d0125794a15

Contents?: true

Size: 1.31 KB

Versions: 3

Compression:

Stored size: 1.31 KB

Contents

module Rainforest
  class Site < ApiResource
    attr_accessor :created_at
    attr_accessor :default
    attr_accessor :id
    attr_accessor :name

    def self.all(params={}, headers={})
      res = client.sites.all(params, headers)
      res
    end

    def self.update(site_id, params={}, headers={})
      res = client.sites.update(site_id, params, headers)
      res
    end

    def self.delete(site_id, params={}, headers={})
      res = client.sites.delete(site_id, params, headers)
      res
    end

    def self.create(params={}, headers={})
      res = client.sites.create(params, headers)
      res
    end

    def update(params={}, headers={})
      res = client.sites.update(id, params, headers)
      self.refresh_from(res.json, res.api_method, res.client)
    end

    def delete(params={}, headers={})
      res = client.sites.delete(id, params, headers)
      res
    end

    def save(params={}, headers={})
      params = ParamsBuilder.merge(api_attributes, params)
      res = client.sites.update(id, params, headers)
      self.refresh_from(res.json, res.api_method, res.client)
    end

    # Everything below here is used behind the scenes.
    ApiResource.register_api_subclass(self, "site")
    @api_attributes = {
      :created_at => {},
      :default => {},
      :id => {},
      :name => {},
    }
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rainforest-2.1.0 lib/rainforest/resources/site.rb
rainforest-2.0.2 lib/rainforest/resources/site.rb
rainforest-2.0.1 lib/rainforest/resources/site.rb