Class: Diva::Type::ModelType
Instance Attribute Summary collapse
-
#model ⇒ Object
readonly
Returns the value of attribute model.
Attributes inherited from MetaType
Instance Method Summary collapse
- #cast(value) ⇒ Object
-
#initialize(model, *rest, &cast) ⇒ ModelType
constructor
A new instance of ModelType.
- #to_s ⇒ Object
Methods inherited from MetaType
Constructor Details
#initialize(model, *rest, &cast) ⇒ ModelType
Returns a new instance of ModelType.
141 142 143 144 |
# File 'lib/diva/type.rb', line 141 def initialize(model, *rest, &cast) super(:model, *rest) @model = model end |
Instance Attribute Details
#model ⇒ Object (readonly)
Returns the value of attribute model.
140 141 142 |
# File 'lib/diva/type.rb', line 140 def model @model end |
Instance Method Details
#cast(value) ⇒ Object
146 147 148 149 |
# File 'lib/diva/type.rb', line 146 def cast(value) raise Diva::InvalidTypeError, "The value is not a `#{model}'." unless value.is_a?(model) value end |
#to_s ⇒ Object
151 152 153 |
# File 'lib/diva/type.rb', line 151 def to_s "#{model} #{name}" end |