Module: Arstotzka::ClassMethods
- Defined in:
- lib/arstotzka/class_methods.rb
Overview
As Arstotzka extends ActiveSupport::Concern, Arstotzka::ClassMethods define methods that will be available when defining a class that includes Arstotka
Instance Method Summary collapse
-
#add_fetcher(attribute, options) ⇒ Artotzka::FetcherBuilder
private
Create builder that will be used to create Fetchers.
-
#expose(*attr_names, **options_hash) ⇒ Array<Sinclair::MethodDefinition>
Expose a field from the json/hash as a method.
-
#fetcher_for(attribute, instance) ⇒ Arstotzka::Fetcher
private
Return the fetcher for an attribute and instance.
Instance Method Details
#add_fetcher(attribute, options) ⇒ Artotzka::FetcherBuilder
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Create builder that will be used to create Fetchers
15 16 17 |
# File 'lib/arstotzka/class_methods.rb', line 15 def add_fetcher(attribute, ) fetcher_builders[attribute.to_sym] = FetcherBuilder.new(.merge(key: attribute)) end |
#expose(*attr_names, **options_hash) ⇒ Array<Sinclair::MethodDefinition>
Expose a field from the json/hash as a method
70 71 72 73 |
# File 'lib/arstotzka/class_methods.rb', line 70 def expose(*attr_names, **) = Options.new(.symbolize_keys) MethodBuilder.new(attr_names, self, ).build end |
#fetcher_for(attribute, instance) ⇒ Arstotzka::Fetcher
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return the fetcher for an attribute and instance
a new fetcher is built everytime this method is called
29 30 31 |
# File 'lib/arstotzka/class_methods.rb', line 29 def fetcher_for(attribute, instance) fetcher_builders[attribute.to_sym].build(instance) end |