Class: RFunk::AttributeVariable
- Inherits:
-
Object
- Object
- RFunk::AttributeVariable
- Defined in:
- lib/rfunk/attribute/attribute_variable.rb
Constant Summary collapse
- ATTRIBUTES_VARIABLE_NAME =
'@attributes'.freeze
Instance Method Summary collapse
Instance Method Details
#add(options) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/rfunk/attribute/attribute_variable.rb', line 5 def add() instance = .fetch(:instance) name = .fetch(:name) attributes = attributes(instance) attributes[name] = RFunk::AttributeType.new(name, .fetch(:type), .fetch(:options)) attributes(instance, attributes) end |
#attributes(*args) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/rfunk/attribute/attribute_variable.rb', line 14 def attributes(*args) instance = args[0] if args.length == 1 instance.instance_variable_get(ATTRIBUTES_VARIABLE_NAME) || {} else instance.instance_variable_set(ATTRIBUTES_VARIABLE_NAME, args[1]) end end |