module ROM::Mapper::DSL::ClassMethods
Class methods for all mappers
@private
Public Instance Methods
Return base_relation
used for creating mapper registry
This is used to “gather” mappers under same root name
@api private
# File lib/rom/mapper/dsl.rb, line 51 def base_relation superclass.relation || relation end
Return header of the mapper
This is memoized so mutating mapper class won't have an effect wrt header after it was initialized for the first time.
TODO: freezing mapper class here is probably a good idea
@api private
# File lib/rom/mapper/dsl.rb, line 63 def header @header ||= dsl.header end
Set base ivars for the mapper class
@api private
# File lib/rom/mapper/dsl.rb, line 25 def inherited(klass) super klass.instance_variable_set('@attributes', nil) klass.instance_variable_set('@header', nil) klass.instance_variable_set('@dsl', nil) end
@api private
# File lib/rom/mapper/dsl.rb, line 68 def respond_to_missing?(name, _include_private = false) dsl.respond_to?(name) || super end
include a registered plugin in this mapper
@param [Symbol] plugin @param [Hash] options @option options [Symbol] :adapter (:default) first adapter to check for plugin
@api public
# File lib/rom/mapper/dsl.rb, line 40 def use(plugin, options = {}) adapter = options.fetch(:adapter, :default) ROM.plugin_registry[:mapper].fetch(plugin, adapter).apply_to(self) end
Private Instance Methods
Return default attributes that might have been inherited from the superclass
@api private
# File lib/rom/mapper/dsl.rb, line 90 def attributes @attributes ||= if superclass.respond_to?(:attributes, true) && inherit_header superclass.attributes.dup else [] end end
Create the attribute DSL
instance used by the mapper class
@api private
# File lib/rom/mapper/dsl.rb, line 102 def dsl @dsl ||= AttributeDSL.new(attributes, options) end