Module: ROM::SQL::TypeExtensions
- Defined in:
- lib/rom/sql/type_extensions.rb
Overview
Type-specific methods
Class Method Summary collapse
-
.[](type) ⇒ Hash
Gets extensions for a type.
-
.register(type) ⇒ Object
Registers a set of operations supported for a specific type.
Class Method Details
.[](type) ⇒ Hash
Gets extensions for a type
17 18 19 |
# File 'lib/rom/sql/type_extensions.rb', line 17 def [](type) @types[type.[:database]][type.[:db_type]] || EMPTY_HASH end |
.register(type) ⇒ Object
Registers a set of operations supported for a specific type
33 34 35 36 37 38 39 40 41 |
# File 'lib/rom/sql/type_extensions.rb', line 33 def register(type, &) extensions = @types[type.[:database]] db_type = type.[:db_type] mod = ::Module.new(&) ctx = ::Object.new.extend(mod) functions = mod.public_instance_methods.to_h { |m| [m, ctx.method(m)] } extensions[db_type] = (extensions[db_type] || {}).merge(functions) end |