Class: Bigqueryid::Coercer
- Inherits:
-
Object
- Object
- Bigqueryid::Coercer
- Defined in:
- lib/bigqueryid/coercer.rb
Instance Attribute Summary collapse
-
#coercer ⇒ Object
readonly
Returns the value of attribute coercer.
-
#schema ⇒ Object
readonly
Returns the value of attribute schema.
Instance Method Summary collapse
- #coerce(name, value) ⇒ Object
-
#initialize(schema, coercer = Coercible::Coercer.new) ⇒ Coercer
constructor
A new instance of Coercer.
Constructor Details
#initialize(schema, coercer = Coercible::Coercer.new) ⇒ Coercer
Returns a new instance of Coercer.
5 6 7 8 |
# File 'lib/bigqueryid/coercer.rb', line 5 def initialize(schema, coercer = Coercible::Coercer.new) @coercer = coercer @schema = schema end |
Instance Attribute Details
#coercer ⇒ Object (readonly)
Returns the value of attribute coercer.
3 4 5 |
# File 'lib/bigqueryid/coercer.rb', line 3 def coercer @coercer end |
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
3 4 5 |
# File 'lib/bigqueryid/coercer.rb', line 3 def schema @schema end |
Instance Method Details
#coerce(name, value) ⇒ Object
10 11 12 13 14 |
# File 'lib/bigqueryid/coercer.rb', line 10 def coerce(name, value) return value if value.nil? || !has_type?(name) coerce_by_type(value, schema[name.to_s][:type]) end |