Class: Pluckr::Result::Builder::Caster
- Inherits:
-
Struct
- Object
- Struct
- Pluckr::Result::Builder::Caster
- Defined in:
- lib/pluckr/result/builder.rb
Overview
Casts one column of a row. default covers SQL returning NULL where the
equivalent ActiveRecord call would not: SUM over no rows is NULL in SQL
and 0 in relation.sum(:column).
Instance Attribute Summary collapse
-
#default ⇒ Object
Returns the value of attribute default.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
Instance Attribute Details
#default ⇒ Object
Returns the value of attribute default
19 20 21 |
# File 'lib/pluckr/result/builder.rb', line 19 def default @default end |
#type ⇒ Object
Returns the value of attribute type
19 20 21 |
# File 'lib/pluckr/result/builder.rb', line 19 def type @type end |
Instance Method Details
#call(value) ⇒ Object
20 21 22 23 24 |
# File 'lib/pluckr/result/builder.rb', line 20 def call(value) return default if value.nil? type ? type.deserialize(value) : value end |