class SmashTheState::Operation::Definition

fundamentally a definition is a re-usable schema block with a name

Attributes

schema_block[R]

Public Class Methods

ref() click to toggle source

the “name” is available as a reference

# File lib/smash_the_state/operation/definition.rb, line 9
def ref
  @definition_name
end
Also aliased as: to_s
to_s()

whenever this module is evaluated as a string, use its name

Alias for: ref

Private Class Methods

definition(definition_name) click to toggle source

assigns a name to the definition

# File lib/smash_the_state/operation/definition.rb, line 19
def definition(definition_name)
  @definition_name = definition_name
end
schema(name = nil, options = {}, &block) click to toggle source
Calls superclass method SmashTheState::Operation::State::schema
# File lib/smash_the_state/operation/definition.rb, line 23
def schema(name = nil, options = {}, &block)
  # if a name is provided, it's an inline schema or a reference to another
  # definition
  return super(name, options, &block) unless name.nil?

  # called with no name, we infer that this is the definition's own schema. the
  # provided schema block is both stored for re-use and also evaluated in the
  # definition module itself
  @schema_block = block
  class_eval(&block)
end