Module: Reins::Model::Schema::ClassMethods
- Defined in:
- lib/reins/model/schema.rb
Instance Method Summary collapse
Instance Method Details
#cast(name, value) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/reins/model/schema.rb', line 17 def cast(name, value) return nil if value.nil? case columns[name.to_s]&.upcase when "INTEGER" then value.to_i when "REAL", "FLOAT", "NUMERIC" then value.to_f when "BOOLEAN", "BOOL" then truthy?(value) else value end end |
#column_names ⇒ Object
13 14 15 |
# File 'lib/reins/model/schema.rb', line 13 def column_names columns.keys end |
#columns ⇒ Object
9 10 11 |
# File 'lib/reins/model/schema.rb', line 9 def columns @columns ||= load_columns end |