Class: Summoner::Attributes

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

Instance Method Summary collapse

Methods inherited from Hash

#symbolize_keys

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



3
4
5
6
7
8
9
10
11
# File 'lib/summoner/attributes.rb', line 3

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