Class: Summoner::Beast
- Inherits:
-
Object
- Object
- Summoner::Beast
- Defined in:
- lib/summoner/beast.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(options = {}, attributes = {}) ⇒ Beast
constructor
A new instance of Beast.
- #method_missing(name, *args, &block) ⇒ Object
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( = {}, attributes = {}) self. = 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
#attributes ⇒ Object
Returns the value of attribute attributes.
3 4 5 |
# File 'lib/summoner/beast.rb', line 3 def attributes @attributes end |
#options ⇒ Object
Returns the value of attribute options.
4 5 6 |
# File 'lib/summoner/beast.rb', line 4 def @options end |