class Loom::Pattern::Pattern

A value object represnting the .loom file pattern declarations. The difference between a Loom::Pattern::Pattern and Loom::Pattern::Reference is a pattern has no association to the context it should run in. It is simply a value object with pointers to its assigned values from the .loom file. However, a Reference includes it's DefinitionContext, including nested before/after/with_facts/let hooks.

Constants

KINDS
KIND_KWARGS

effectively, a list of `attr_readers` for the Pattern kind. but also used for validation

Attributes

description[R]
kind[R]
name[R]
pattern_block[R]

Public Class Methods

new(name: nil, description: nil, kind: nil, **kind_kwargs, &block) click to toggle source
# File lib/loom/pattern/pattern.rb, line 21
def initialize(name: nil, description: nil, kind: nil, **kind_kwargs, &block)
  @name = name
  @description = description
  @kind = kind
  @pattern_block = block

  @valid_kwargs = KIND_KWARGS[kind]
  kind_kwargs.each do |k, _|
    raise "unknown kind_kwarg: #{k}" unless @valid_kwargs.include? k
  end
  @kind_properties_struct = OpenStruct.new kind_kwargs
end