Module: Mediakit::Utils::ConstantFactory::ClassMethods

Defined in:
lib/mediakit/utils/constant_factory.rb

Instance Method Summary collapse

Instance Method Details

#create_constant(name, attributes) ⇒ Object

Raises:

  • (ArgumentError)


22
23
24
25
26
27
28
29
30
31
# File 'lib/mediakit/utils/constant_factory.rb', line 22

def create_constant(name, attributes)
  raise(
    ArgumentError,
    <<EOS
you can give attribute keys which only defined by `using_attributes` and that is satisfied all keys.'
EOS
  ) unless Set.new(using_attributes) == Set.new(attributes.keys)
  return self.const_get(name) if self.const_defined?(name)
  self.const_set(name, new(attributes).freeze)
end

#using_attributesObject

Raises:

  • (NotImplementedError)


18
19
20
# File 'lib/mediakit/utils/constant_factory.rb', line 18

def using_attributes
  raise(NotImplementedError)
end