Class: DataGuru::Client
- Inherits:
-
Object
show all
- Defined in:
- lib/data_guru/client.rb
Instance Method Summary
collapse
Constructor Details
#initialize(api_url: nil, access_token: nil) ⇒ Client
Returns a new instance of Client.
6
7
8
9
10
11
|
# File 'lib/data_guru/client.rb', line 6
def initialize(api_url: nil, access_token: nil)
if api_url.present? && access_token.present?
DataGuru.config = Configuration.new(api_url: api_url,
access_token: access_token)
end
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name) ⇒ Object
13
14
15
16
17
|
# File 'lib/data_guru/client.rb', line 13
def method_missing(name)
create_model_class(name) if should_create_class?(name)
value = DataGuru::Collection.new(collection_name: name, model: model(name))
get_variable(name) || set_variable(name, value)
end
|
Instance Method Details
#errors ⇒ Object
24
25
26
|
# File 'lib/data_guru/client.rb', line 24
def errors
DataGuru::Validation.new.errors
end
|
#refresh ⇒ Object
19
20
21
22
|
# File 'lib/data_guru/client.rb', line 19
def refresh
HTTParty.get(refresh_data_url)
wipe_collections_cache
end
|