class GoodData::Rest::ObjectFactory
Bridge between Rest::Object
and Rest::Connection
MUST be Responsible for creating new Rest::Object
instances using proper Rest::Connection
SHOULD be used for throttling, statistics, custom ‘allocation strategies’ …
Attributes
Public Class Methods
Source
# File lib/gooddata/rest/object_factory.rb, line 25 def initialize(client) fail ArgumentError 'Invalid connection passed' if client.nil? @client = client # Set connection used by factory @connection = @client.connection end
Initializes instance of factory
@param connection [GoodData::Rest::Connection] Connection
used by factory @return [GoodData::Rest::ObjectFactory] Factory instance
Public Instance Methods
Source
# File lib/gooddata/rest/object_factory.rb, line 34 def create(type, data = {}, opts = {}) res = type.new(data) res.client = client opts.each do |key, value| method = "#{key}=" res.send(method, value) if res.respond_to?(method) end res end
Source
# File lib/gooddata/rest/object_factory.rb, line 46 def find(type, opts = {}) type.send('find', opts, @client) end