Class: Materialize::Repo

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/materialize/repo.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils

#class_exists?

Constructor Details

#initialize(token = nil) ⇒ Repo

Returns a new instance of Repo.



7
8
9
# File 'lib/materialize/repo.rb', line 7

def initialize(token = nil)
  @token = token
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(query, *args, &block) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/materialize/repo.rb', line 11

def method_missing(query, *args, &block)
  data_source_class = args[0]
  options           = args[1] || {}
  args_to_pass      = options[:args]

  data, builder_class = process(data_source_class, query, args_to_pass)
  options.delete(:args)

  if data.is_a?(Hash) and !data['message'].nil?
 Response.new data
  elsif data.is_a?(Array)
    builder_class.build_all(data, self, options)
  else
    builder_class.build(data, self, options)
  end
end

Instance Attribute Details

#tokenObject (readonly)

Returns the value of attribute token.



5
6
7
# File 'lib/materialize/repo.rb', line 5

def token
  @token
end