Sha256: 26e244892c0922b298af15b57a4260ce82825171c589b146c2a06ef78bf615a3
Contents?: true
Size: 801 Bytes
Versions: 3
Compression:
Stored size: 801 Bytes
Contents
module Koine module Attributes class AttributesFactory def initialize(options = {}) @adapters = {} @options = options end def create(target_object) Attributes.new(target_object, adapters: @adapters, options: @options) end 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 def coerce_adapter(adapter) return adapter unless adapter.instance_of?(::Symbol) Object.const_get("Koine::Attributes::Adapter::#{adapter.to_s.capitalize}").new end def freeze super @adapters.freeze @options.freeze end end end end
Version data entries
3 entries across 3 versions & 1 rubygems