rubyist-aasm 0.0.2 → 2.0.0

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.
data/CHANGELOG CHANGED
@@ -1,3 +1,5 @@
1
+ * Incremented version number
2
+ * Cleaned up aasm_states_for_select to return the value as a string
1
3
  * Specs and bug fixes for the ActiveRecordPersistence, keeping persistence columns in sync
2
4
  Allowing for nil values in states for active record
3
5
  Only set state to default state before_validation_on_create
data/README.rdoc CHANGED
@@ -6,10 +6,10 @@ AASM started as the acts_as_state_machine plugin but has evolved into a more gen
6
6
 
7
7
  AASM has the following features:
8
8
 
9
- * Feature
10
-
11
- * Feature
12
-
9
+ * States
10
+ * Machines
11
+ * Events
12
+ * Transitions
13
13
 
14
14
  == Download
15
15
 
@@ -23,10 +23,15 @@ A release and a gem are forthcoming.
23
23
 
24
24
  == Installation
25
25
 
26
- Until the gem release is made your best bet is to build the gem yourself and install it.
26
+ === From GitHub hosted gems
27
+
28
+ % sudo gem sources -a http://gems.github.com # (you only need to do this once)
29
+ % sudo gem install rubyist-aasm
30
+
31
+ === Building your own gems
27
32
 
28
33
  % rake gem
29
- % sudo gem install pkg/aasm-3.0.0.gem
34
+ % sudo gem install pkg/aasm-0.0.2.gem
30
35
 
31
36
 
32
37
  == Simple Example
data/lib/aasm.rb CHANGED
@@ -33,9 +33,9 @@ module AASM
33
33
  end
34
34
  end
35
35
 
36
- def aasm_event(name, &block)
36
+ def aasm_event(name, options = {}, &block)
37
37
  unless aasm_events.has_key?(name)
38
- aasm_events[name] = AASM::SupportingClasses::Event.new(name, &block)
38
+ aasm_events[name] = AASM::SupportingClasses::Event.new(name, options, &block)
39
39
  end
40
40
 
41
41
  define_method("#{name.to_s}!") do
@@ -46,6 +46,9 @@ module AASM
46
46
  end
47
47
 
48
48
  self.aasm_current_state_with_persistence = new_state
49
+
50
+ self.send(self.class.aasm_events[name].success) if self.class.aasm_events[name].success
51
+
49
52
  true
50
53
  else
51
54
  if self.respond_to?(:aasm_event_failed)
@@ -85,7 +88,7 @@ module AASM
85
88
  end
86
89
 
87
90
  def aasm_states_for_select
88
- aasm_states.collect { |state| [state.to_s.gsub(/_/, ' ').capitalize, state] }
91
+ aasm_states.collect { |state| [state.to_s.gsub(/_/, ' ').capitalize, state.to_s] }
89
92
  end
90
93
 
91
94
  end
data/lib/event.rb CHANGED
@@ -3,10 +3,11 @@ require File.join(File.dirname(__FILE__), 'state_transition')
3
3
  module AASM
4
4
  module SupportingClasses
5
5
  class Event
6
- attr_reader :name
6
+ attr_reader :name, :success
7
7
 
8
- def initialize(name, &block)
8
+ def initialize(name, options = {}, &block)
9
9
  @name = name
10
+ @success = options[:success]
10
11
  @transitions = []
11
12
  instance_eval(&block) if block
12
13
  end
data/lib/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module AASM
2
2
  module VERSION
3
- STRING = '3.0.0'
3
+ STRING = '0.0.2'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubyist-aasm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Barron
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-04-29 00:00:00 -07:00
12
+ date: 2008-05-14 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15