Module: Tutor::Attributes::Type
- Included in:
- Attribute
- Defined in:
- lib/tutor/attributes/type.rb
Instance Attribute Summary collapse
-
#nullable ⇒ Object
Returns the value of attribute nullable.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
Instance Attribute Details
#nullable ⇒ Object
Returns the value of attribute nullable.
3 4 5 |
# File 'lib/tutor/attributes/type.rb', line 3 def nullable @nullable end |
#type ⇒ Object
Returns the value of attribute type.
3 4 5 |
# File 'lib/tutor/attributes/type.rb', line 3 def type @type end |
Instance Method Details
#check_value_type!(value) ⇒ Object
11 12 13 14 |
# File 'lib/tutor/attributes/type.rb', line 11 def check_value_type!(value) raise ArgumentError.new("Invalid value type assigned to attribute!") unless self.valid_value_type?(value) true end |
#valid_value_type?(value) ⇒ Boolean
7 8 9 |
# File 'lib/tutor/attributes/type.rb', line 7 def valid_value_type?(value) self.type.nil? || (self.nullable && value.nil?) || !(value.class <= self.type).nil? end |