Class: ActiveType::TypeCaster
- Inherits:
-
Object
- Object
- ActiveType::TypeCaster
- Defined in:
- lib/active_type/type_caster.rb
Defined Under Namespace
Modules: NativeCasters
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(type, native_caster) ⇒ TypeCaster
constructor
A new instance of TypeCaster.
- #native_type_cast_from_user(value) ⇒ Object
- #type_cast_from_user(value) ⇒ Object
Constructor Details
#initialize(type, native_caster) ⇒ TypeCaster
9 10 11 12 |
# File 'lib/active_type/type_caster.rb', line 9 def initialize(type, native_caster) @type = type @native_caster = native_caster end |
Class Method Details
.get(type) ⇒ Object
4 5 6 7 |
# File 'lib/active_type/type_caster.rb', line 4 def self.get(type) native_caster = NativeCasters::DelegateToRailsType.new(type) new(type, native_caster) end |
Instance Method Details
#native_type_cast_from_user(value) ⇒ Object
27 28 29 |
# File 'lib/active_type/type_caster.rb', line 27 def native_type_cast_from_user(value) @native_caster.type_cast_from_user(value) end |
#type_cast_from_user(value) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/active_type/type_caster.rb', line 14 def type_cast_from_user(value) # For some reason, Rails defines additional type casting logic # outside the classes that have that responsibility. case @type when :integer cast_integer(value) when :timestamp, :datetime cast_time(value) else native_type_cast_from_user(value) end end |