Sha256: d651c5210109c9dbaf7bc7c08fd661a595d5e39b92477d4113149674a7cd5018

Contents?: true

Size: 1.96 KB

Versions: 1

Compression:

Stored size: 1.96 KB

Contents

module Rainforest
  class Generator < ApiResource
    attr_accessor :columns
    attr_accessor :created_at
    attr_accessor :description
    attr_accessor :generator_type
    attr_accessor :id
    attr_accessor :name
    attr_accessor :row_count

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

    def self.retrieve(generator_id, params={}, headers={})
      res = client.generators.retrieve(generator_id, params, headers)
      res
    end

    def self.update(generator_id, params={}, headers={})
      res = client.generators.update(generator_id, params, headers)
      res
    end

    def self.delete(generator_id, params={}, headers={})
      res = client.generators.delete(generator_id, params, headers)
      res
    end

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

    def refresh(params={}, headers={})
      res = client.generators.retrieve(id, params, headers)
      self.refresh_from(res.json, res.api_method, res.client)
    end

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

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

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

    def rows()
      GeneratorRowsEndpoint.new(client, self)
    end

    # Everything below here is used behind the scenes.
    ApiResource.register_api_subclass(self, "generator")
    @api_attributes = {
      :columns => {},
      :created_at => {},
      :description => { :editable => true },
      :generator_type => {},
      :id => {},
      :name => { :editable => true },
      :row_count => {},
    }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rainforest-2.0.0 lib/rainforest/resources/generator.rb