class MtgApi::RequestEntity

represents an entity being returned from the API

Attributes

config[RW]

the stored Config instance for this class

Public Class Methods

configure(&block) click to toggle source

build a config and evaluate the block inside of it

# 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
new(attributes = {}) click to toggle source

build a card set from a set of attributes

# 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

Private Class Methods

query_builder() click to toggle source

build a query builder whenever query methods are called on this class

# File lib/mtg_api/request_entity.rb, line 42
def query_builder
  QueryBuilder.new(self)
end

Public Instance Methods

attributes() click to toggle source

the attributes of this request entity

# File lib/mtg_api/request_entity.rb, line 14
def attributes
  self.class.config.full_config.map { |attribute| [attribute, send(attribute)] }.to_h
end