Class: Summoner::Beast

Inherits:
Object
  • Object
show all
Defined in:
lib/summoner/beast.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}, attributes = {}) ⇒ Beast

Returns a new instance of Beast.



6
7
8
9
# File 'lib/summoner/beast.rb', line 6

def initialize(options = {}, attributes = {})
  self.options    = options
  self.attributes = attributes
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/summoner/beast.rb', line 11

def method_missing(name, *args, &block)
  if name == :has_one
    self.attributes[args.first]   = Summoner.invoke args.first
  elsif name == :has_many
    self.attributes[args.first]   = [Summoner.invoke(args.first)]
  else
    self.attributes[name.to_sym]  = args.first
  end
  self
end

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



3
4
5
# File 'lib/summoner/beast.rb', line 3

def attributes
  @attributes
end

#optionsObject

Returns the value of attribute options.



4
5
6
# File 'lib/summoner/beast.rb', line 4

def options
  @options
end