omg-statelogic 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. data/lib/statelogic/activerecord.rb +4 -2
  2. metadata +2 -2
@@ -47,6 +47,8 @@ module Statelogic
47
47
  def initial_state(name, options = {}, &block)
48
48
  state(name, options.update(:initial => true), &block)
49
49
  end
50
+
51
+ alias initial initial_state
50
52
 
51
53
  def state(name, options = {}, &block)
52
54
  attr = @config[:attribute]
@@ -71,8 +73,8 @@ module Statelogic
71
73
 
72
74
  ConfigHelper.new(self, options).instance_eval(&block)
73
75
 
74
- initial = options[:initial] || options[:states]
75
- validates_inclusion_of attr, :in => initial, :on => :create unless initial.blank?
76
+ initial = [options[:initial], options[:states]].find {|x| !x.blank? }
77
+ validates_inclusion_of attr, :in => initial, :on => :create if initial
76
78
 
77
79
  const = attr.to_s.pluralize.upcase
78
80
  const_set(const, options[:states].freeze.each(&:freeze)) unless const_defined?(const)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omg-statelogic
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Gunko
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-06-21 00:00:00 -07:00
12
+ date: 2009-06-23 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency