Class: MtgApi::RequestEntity
- Inherits:
-
Object
- Object
- MtgApi::RequestEntity
- Extended by:
- Forwardable
- Defined in:
- lib/mtg_api/request_entity.rb
Overview
represents an entity being returned from the API
Class Attribute Summary collapse
-
.config ⇒ Object
the stored Config instance for this class.
Class Method Summary collapse
-
.configure(&block) ⇒ Object
build a config and evaluate the block inside of it.
Instance Method Summary collapse
-
#attributes ⇒ Object
the attributes of this request entity.
-
#initialize(attributes = {}) ⇒ RequestEntity
constructor
build a card set from a set of attributes.
Constructor Details
#initialize(attributes = {}) ⇒ RequestEntity
build a card set from a set of attributes
7 8 9 10 11 |
# File 'lib/mtg_api/request_entity.rb', line 7 def initialize(attributes = {}) attributes.each do |key, value| send(:"#{key}=", value) if respond_to?(:"#{key}=") end end |
Class Attribute Details
.config ⇒ Object
the stored Config instance for this class
20 21 22 |
# File 'lib/mtg_api/request_entity.rb', line 20 def config @config end |
Class Method Details
.configure(&block) ⇒ Object
build a config and evaluate the block inside of it
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/mtg_api/request_entity.rb', line 27 def configure(&block) self.config = Config.new(self) config.instance_eval(&block) attr_accessor *config.accessors attr_reader *config.setters.keys config.setters.each do |name, definition| define_method(:"#{name}=", definition) end end |
Instance Method Details
#attributes ⇒ Object
the attributes of this request entity
14 15 16 |
# File 'lib/mtg_api/request_entity.rb', line 14 def attributes self.class.config.full_config.map { |attribute| [attribute, send(attribute)] }.to_h end |