class FluxTuna::Witness::AbstractWitness

@abstract Defines the core {Witness} class

Public Class Methods

new(shatter, mutate, bind) click to toggle source

Default constructor. The names of the shatter, mutate and bind class to use for this {Witness} must be passed in. These will be called in place of the the methods of this class when appropriate.

# File lib/witness/abstract_witness.rb, line 28
def initialize(shatter, mutate, bind)
  shatter_string = "Witness::Shatter::" + shatter.to_s
  @shatter = shatter_string.to_sym
  
  mutate_string = "Witness::Mutate::" + shatter.to_s
  @mutate = mutate_string.to_sym
  
  bind_string = "Witness::Bind::" + shatter.to_s
  @bind = bind_string.to_sym
end

Public Instance Methods

bind() click to toggle source

Calls the named bind class to create the representation tree

# File lib/witness/abstract_witness.rb, line 50
def bind
  call_bind {}
end
mutate() click to toggle source

Calls the named bind class to mutate the representation

# File lib/witness/abstract_witness.rb, line 45
def mutate
  call_mutate {}
end
shatter() click to toggle source

Calls the named shatter class to break the original structure

# File lib/witness/abstract_witness.rb, line 40
def shatter
  call_shatter {}
end

Private Instance Methods

call_bind(&block) click to toggle source

Calls the named bind class to create the representation tree

# File lib/witness/abstract_witness.rb, line 65
def call_bind(&block)
  Object.const_get(@bind).send(:bind)
end
call_mutate(&block) click to toggle source

Calls the named bind class to mutate the representation

# File lib/witness/abstract_witness.rb, line 60
def call_mutate(&block)
  Object.const_get(@mutate).send(:mutate)
end
call_shatter(&block) click to toggle source

Calls the named shatter class to break the original structure

# File lib/witness/abstract_witness.rb, line 55
def call_shatter(&block)
  Object.const_get(@shatter).send(:shatter)
end