Module: RFunk::Attribute::ClassMethods
- Defined in:
- lib/rfunk/attribute/attribute.rb
Instance Method Summary collapse
Instance Method Details
#attribute(name, type, options = {}) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rfunk/attribute/attribute.rb', line 14 def attribute(name, type, = {}) AttributeVariable.new.add(instance: self, name: name, type: type, options: ) define_method(name) { |value = nil| if value ErrorChecking.new.raise_expected_type(name, value, type) Immutable.new.create(instance: self, variable_name: variable_name(name), value: value) else Option(self.instance_variable_get(variable_name(name))) end } end |