Class: Toy::List
Instance Attribute Summary collapse
-
#model ⇒ Object
Returns the value of attribute model.
-
#name ⇒ Object
Returns the value of attribute name.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #eql?(other) ⇒ Boolean (also: #==)
- #extensions ⇒ Object
-
#initialize(model, name, *args, &block) ⇒ List
constructor
A new instance of List.
- #instance_variable ⇒ Object
- #key ⇒ Object
- #new_proxy(owner) ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(model, name, *args, &block) ⇒ List
Returns a new instance of List.
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/toy/list.rb', line 7 def initialize(model, name, *args, &block) @model = model @name = name.to_sym @options = args. @type = args.shift model.send(list_method)[name] = self [:extensions] = modularized_extensions(block, [:extensions]) model.attribute(key, .fetch(:attribute_type) { Array }) create_accessors end |
Instance Attribute Details
#model ⇒ Object
Returns the value of attribute model.
5 6 7 |
# File 'lib/toy/list.rb', line 5 def model @model end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/toy/list.rb', line 5 def name @name end |
#options ⇒ Object
Returns the value of attribute options.
5 6 7 |
# File 'lib/toy/list.rb', line 5 def @options end |
Instance Method Details
#eql?(other) ⇒ Boolean Also known as: ==
41 42 43 44 45 |
# File 'lib/toy/list.rb', line 41 def eql?(other) self.class.eql?(other.class) && model == other.model && name == other.name end |
#extensions ⇒ Object
37 38 39 |
# File 'lib/toy/list.rb', line 37 def extensions [:extensions] end |
#instance_variable ⇒ Object
29 30 31 |
# File 'lib/toy/list.rb', line 29 def instance_variable @instance_variable ||= :"@_#{name}" end |
#key ⇒ Object
25 26 27 |
# File 'lib/toy/list.rb', line 25 def key @key ||= :"#{name.to_s.singularize}_ids" end |
#new_proxy(owner) ⇒ Object
33 34 35 |
# File 'lib/toy/list.rb', line 33 def new_proxy(owner) proxy_class.new(self, owner) end |
#type ⇒ Object
21 22 23 |
# File 'lib/toy/list.rb', line 21 def type @type ||= name.to_s.classify.constantize end |