class Koine::Attributes::AttributesFactory

Public Class Methods

new(options = {}) click to toggle source
# File lib/koine/attributes/attributes_factory.rb, line 6
def initialize(options = {})
  @adapters = {}
  @options = options
end

Public Instance Methods

add_attribute(name, adapter) { |adapter| ... } click to toggle source
# File lib/koine/attributes/attributes_factory.rb, line 15
def add_attribute(name, adapter, &block)
  adapter = coerce_adapter(adapter)
  adapter.with_attribute_name(name)
  yield(adapter) if block
  @adapters[name.to_sym] = adapter.freeze
end
coerce_adapter(adapter) click to toggle source
# File lib/koine/attributes/attributes_factory.rb, line 22
def coerce_adapter(adapter)
  return adapter unless adapter.instance_of?(::Symbol)

  Object.const_get("Koine::Attributes::Adapter::#{adapter.to_s.capitalize}").new
end
create(target_object) click to toggle source
# File lib/koine/attributes/attributes_factory.rb, line 11
def create(target_object)
  Attributes.new(target_object, adapters: @adapters, options: @options)
end
freeze() click to toggle source
Calls superclass method
# File lib/koine/attributes/attributes_factory.rb, line 28
def freeze
  super
  @adapters.freeze
  @options.freeze
end