Module: Apollo::ClassMethods

Defined in:
lib/apollo.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#apollo_specObject (readonly)

Returns the value of attribute apollo_spec.



26
27
28
# File 'lib/apollo.rb', line 26

def apollo_spec
  @apollo_spec
end

Instance Method Details

#apollo(&specification) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/apollo.rb', line 37

def apollo(&specification)
  @apollo_spec = Specification.new(Hash.new, &specification)
  @apollo_spec.states.values.each do |state|
    state_name = state.name
    module_eval do
      define_method "#{state_name}?" do
        state_name == current_state.name
      end
    end

    state.events.values.each do |event|
      event_name = event.name
      module_eval do
        define_method "#{event_name}!".to_sym do |*args|
          process_event!(event_name, *args)
        end
      end
    end
  end
end

#apollo_column(column_name = nil) ⇒ Object



28
29
30
31
32
33
34
35
# File 'lib/apollo.rb', line 28

def apollo_column(column_name=nil)
  if column_name
    @apollo_state_column_name = column_name.to_sym
  else
    @apollo_state_column_name ||= :current_state
  end
  @apollo_state_column_name
end