Sha256: f1575080113d4a15cbc71b1b9ddbdc1a510a3db21a69dfe759703c8691babf40
Contents?: true
Size: 833 Bytes
Versions: 1
Compression:
Stored size: 833 Bytes
Contents
# frozen_string_literal: true 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
koine-attributes-1.2.4 | lib/koine/attributes/attributes_factory.rb |