Class: Entitize::Repo
- Inherits:
-
Object
- Object
- Entitize::Repo
- Defined in:
- lib/entitize/repo.rb
Instance Attribute Summary collapse
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
-
#initialize(settings = {}) ⇒ Repo
constructor
A new instance of Repo.
- #method_missing(query, *args, &block) ⇒ Object
Constructor Details
#initialize(settings = {}) ⇒ Repo
Returns a new instance of Repo.
6 7 8 |
# File 'lib/entitize/repo.rb', line 6 def initialize(settings = {}) @token = settings[:token] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(query, *args, &block) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/entitize/repo.rb', line 10 def method_missing(query, *args, &block) data_source_class = args[0] = args[1] || {} arguments = [:args] || [] class_name_to_use = [:entity] || data_source_class.to_s # TODO: add in all settings as first args -> e.g. pub_key, secret_key arguments.unshift(token) unless token.nil? data = data_source_class.send(query, *arguments) Entitize::Entity.generate(data, class_name_to_use) end |
Instance Attribute Details
#token ⇒ Object (readonly)
Returns the value of attribute token.
4 5 6 |
# File 'lib/entitize/repo.rb', line 4 def token @token end |