Module: ValueSemantics::ClassMethods

Defined in:
lib/value_semantics/class_methods.rb

Overview

All the class methods available on ValueSemantics classes

When a ValueSemantics module is included into a class, the class is extended by this module.

Instance Method Summary collapse

Instance Method Details

#coercer#call

A coercer object for the value class

This is mostly useful when nesting value objects inside each other.

Returns:

  • (#call)

    A callable object that can be used as a coercer

See Also:



30
31
32
# File 'lib/value_semantics/class_methods.rb', line 30

def coercer
  ValueObjectCoercer.new(self)
end

#value_semanticsRecipe

Returns the recipe used to build the ValueSemantics module that was included into this class.

Returns:

  • (Recipe)

    the recipe used to build the ValueSemantics module that was included into this class.



13
14
15
16
17
18
19
20
# File 'lib/value_semantics/class_methods.rb', line 13

def value_semantics
  if block_given?
    # caller is trying to use the monkey-patched Class method
    raise "`#{self}` has already included ValueSemantics"
  end

  self::VALUE_SEMANTICS_RECIPE__
end