Module: Monies::Serialization::ActiveRecord::ClassMethods
- Defined in:
- lib/monies/serialization/active_record.rb
Instance Method Summary collapse
- #predicate_builder ⇒ Object
- #serialize_monies(column, currency: nil) ⇒ Object
- #serialize_monies_string(column) ⇒ Object
Instance Method Details
#predicate_builder ⇒ Object
19 20 21 |
# File 'lib/monies/serialization/active_record.rb', line 19 def predicate_builder @predicate_builder ||= super().tap { _1.register_handler(Monies, PredicateBuilderHandler.new(_1, self)) } end |
#serialize_monies(column, currency: nil) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/monies/serialization/active_record.rb', line 5 def serialize_monies(column, currency: nil) if currency.is_a?(Symbol) && !column_names.include?(currency.to_s) raise RuntimeError, "missing currency column #{currency.inspect}" end column_type = columns.find { _1.name == column.to_s }..type serialize_monies_attribute(column, column_type, currency) end |
#serialize_monies_string(column) ⇒ Object
15 16 17 |
# File 'lib/monies/serialization/active_record.rb', line 15 def serialize_monies_string(column) serialize(column, coder: Monies) end |