Module: Attrify::ClassMethods

Defined in:
lib/attrify.rb

Instance Method Summary collapse

Instance Method Details

#attributesObject



14
15
16
17
18
19
20
21
# File 'lib/attrify.rb', line 14

def attributes(&)
  result = DSL::Engine.new.build(&)
  config = variant_registry
  config.base = result.base_attr
  config.variants = result.variants
  config.compounds = result.compounds
  config.defaults = result.defaults
end

#variant_registryObject



23
24
25
26
27
28
29
30
# File 'lib/attrify.rb', line 23

def variant_registry
  @variant_registry ||=
    if superclass.respond_to?(:variant_registry)
      superclass.variant_registry.dup
    else
      VariantRegistry.new
    end
end