Class: Setsumei::Describable::ObjectAttribute
- Inherits:
-
Object
- Object
- Setsumei::Describable::ObjectAttribute
- Defined in:
- lib/setsumei/describable/object_attribute.rb
Instance Attribute Summary collapse
-
#klass ⇒ Object
Returns the value of attribute klass.
-
#name ⇒ Object
Returns the value of attribute name.
-
#options ⇒ Object
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ ObjectAttribute
constructor
A new instance of ObjectAttribute.
- #is_an_attribute_of_type?(type) ⇒ Boolean
- #set_value_on(object, options) ⇒ Object
- #value_for(data) ⇒ Object
Constructor Details
#initialize ⇒ ObjectAttribute
Returns a new instance of ObjectAttribute.
17 18 19 |
# File 'lib/setsumei/describable/object_attribute.rb', line 17 def initialize self.klass = Object end |
Instance Attribute Details
#klass ⇒ Object
Returns the value of attribute klass.
15 16 17 |
# File 'lib/setsumei/describable/object_attribute.rb', line 15 def klass @klass end |
#name ⇒ Object
Returns the value of attribute name.
15 16 17 |
# File 'lib/setsumei/describable/object_attribute.rb', line 15 def name @name end |
#options ⇒ Object
Returns the value of attribute options.
15 16 17 |
# File 'lib/setsumei/describable/object_attribute.rb', line 15 def @options end |
Class Method Details
.named(name, options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/setsumei/describable/object_attribute.rb', line 5 def ObjectAttribute.named(name, = {}) = .dup raise ArgumentError.new("you must specify what the object is") unless .has_key? :as_a new.tap do |attribute| attribute.name = name attribute.klass = .delete(:as_a) attribute. = end end |
Instance Method Details
#is_an_attribute_of_type?(type) ⇒ Boolean
31 32 33 |
# File 'lib/setsumei/describable/object_attribute.rb', line 31 def is_an_attribute_of_type?(type) type == :object || type == self.class || type == self.klass end |
#set_value_on(object, options) ⇒ Object
35 36 37 |
# File 'lib/setsumei/describable/object_attribute.rb', line 35 def set_value_on(object, ) object.send accessor, value_from_hash([:from_value_in]) end |