Module: Yasm::Context

Defined in:
lib/yasm/context.rb,
lib/yasm/context/state_container.rb,
lib/yasm/context/state_configuration.rb,
lib/yasm/context/anonymous_state_identifier.rb,
lib/yasm/context/state_configuration/action_hook.rb

Defined Under Namespace

Modules: ClassMethods Classes: StateConfiguration, StateContainer

Constant Summary collapse

ANONYMOUS_STATE =
:yasm_anonymous_state

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



3
4
5
6
7
8
# File 'lib/yasm/context.rb', line 3

def self.included(base)
  base.extend ClassMethods
  if defined?(CouchRest) and defined?(CouchRest::Model) and base.ancestors.include?(CouchRest::Model::Base) and !base.ancestors.include?(Yasm::Persistence::CouchRest::Model)
    base.send :include, Yasm::Persistence::CouchRest::Model
  end
end

Instance Method Details

#do!(*actions) ⇒ Object



46
47
48
# File 'lib/yasm/context.rb', line 46

def do!(*actions)
  state.do! *actions
end

#fast_forwardObject



55
56
57
# File 'lib/yasm/context.rb', line 55

def fast_forward
  self.class.state_configurations.keys.each { |state_name| state_container(state_name).value }
end

#stateObject



50
51
52
53
# File 'lib/yasm/context.rb', line 50

def state
  raise "This class has no anonymous state" unless self.class.state_configurations[ANONYMOUS_STATE] 
  state_container ANONYMOUS_STATE
end