module ActsAsHashable::Factory
This class serves as a singleton that can make mapped acts_as_hashable components. It is important to note that these components must be acts_as_hashable objects. In order to use you just have to subclass this class and implement a method called 'registry', such as:
def registry { 'Table': Table, 'Text': Text } end
You can also use the 'register' DSL:
register 'some_class_name', SomeClassName register 'some_class_name', '', SomeClassName
or:
register 'some_class_name', ->(_key) { SomeClassName }
Public Instance Methods
register(*args)
click to toggle source
# File lib/acts_as_hashable/factory.rb, line 31 def register(*args) raise ArgumentError, "missing at least one key and value: #{args}" if args.length < 2 value = args.last args[0..-2].each do |key| registry[key] = value end end
Private Instance Methods
factory()
click to toggle source
# File lib/acts_as_hashable/factory.rb, line 62 def factory @factory ||= TypeFactory.new(materialize_registry, typed_with) end