Module: Obvious::EntityMixin::ClassMethods
- Defined in:
- lib/obvious/entity.rb
Instance Attribute Summary collapse
-
#shape ⇒ Object
readonly
Returns the value of attribute shape.
-
#validations ⇒ Object
readonly
Returns the value of attribute validations.
Instance Method Summary collapse
Instance Attribute Details
#shape ⇒ Object (readonly)
Returns the value of attribute shape.
12 13 14 |
# File 'lib/obvious/entity.rb', line 12 def shape @shape end |
#validations ⇒ Object (readonly)
Returns the value of attribute validations.
13 14 15 |
# File 'lib/obvious/entity.rb', line 13 def validations @validations end |
Instance Method Details
#validation(name, method) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/obvious/entity.rb', line 22 def validation name, method name = "#{name}_validation".to_sym @validations ||= [] @validations << name define_method(name) { instance_exec &method } end |
#value(name, type) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/obvious/entity.rb', line 15 def value name, type name = name.to_sym @shape ||= {} @shape[name] = type define_method(name) { @values[name] } end |