pipa-statelogic 0.0.3 → 0.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -21,7 +21,7 @@ http://pipa.lighthouseapp.com/projects/22857-statelogic
21
21
  === Example
22
22
  class Order < ActiveRecord::Base
23
23
  ...
24
- statelogic do
24
+ statelogic :attribute => :state do # +:state+ is the default value, may be omitted
25
25
  # you get methods +unpaid?+ and +was_unpaid?+.
26
26
  # may be more than one initial state.
27
27
  initial_state 'unpaid' do
@@ -14,7 +14,7 @@ module Statelogic
14
14
  MACROS_PATTERN = /\Avalidates_/.freeze
15
15
 
16
16
  def initialize(cl, state, config)
17
- @class, @state, @config, @conditions = cl, state, config, state.map {|x| :"#{x}?"}
17
+ @class, @state, @config = cl, state, config
18
18
  end
19
19
 
20
20
  def validates_transition_to(*states)
@@ -32,7 +32,7 @@ module Statelogic
32
32
  if CALLBACKS.include?(method) || method.to_s =~ MACROS_PATTERN
33
33
  options = args.last
34
34
  args.push(options = {}) unless options.is_a?(Hash)
35
- options[:if] = Array(options[:if]).unshift(@conditions)
35
+ options[:if] = Array(options[:if]).unshift(:"#{@state}?")
36
36
  @class.send(method, *args, &block)
37
37
  else
38
38
  super
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pipa-statelogic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: "0.1"
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Gunko