simplestate 0.1.3 → 0.1.4
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.
- checksums.yaml +4 -4
- data/README.md +10 -2
- data/lib/simplestate/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: dc65445caaa1cac7f1bd911084c8e37f488ec29f
|
|
4
|
+
data.tar.gz: a41b3380697b0a2ede4571e914a1f5d42e0ab5fc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b2f89ec0b6bc96f99f6d1948eec4b21e39d44928b52ac2b622d13b05d86b2ae665fc92a38724516a74102833159a9c2c5b85c1cdb4bf3bc0042700c748874926
|
|
7
|
+
data.tar.gz: 01c95d3b96244ca3f7a0b335733500ac6caa85a656d82df741ca378a8304db65c3fd4f4cc39cabb233574d23143b87f1655172452337b2d7dfd7eb853794da60
|
data/README.md
CHANGED
|
@@ -29,9 +29,17 @@ Inherit from StateHolder to create the class of objects that will hold states:
|
|
|
29
29
|
|
|
30
30
|
```ruby
|
|
31
31
|
class Button < StateHolder
|
|
32
|
+
attr_reader :color
|
|
33
|
+
def initialize(opts={})
|
|
34
|
+
@color = opts.fetch :color
|
|
35
|
+
super
|
|
36
|
+
end
|
|
37
|
+
|
|
32
38
|
# button methods here
|
|
33
39
|
end
|
|
34
40
|
```
|
|
41
|
+
If you want to set additional attributes at creation of a new button, new is called with an opts hash. Set the attribute from the opts hash in initialize. You !must! call super if you provide an initialize method in your holder class.
|
|
42
|
+
|
|
35
43
|
Inherit from State to create a class to provide specific state behaviors:
|
|
36
44
|
|
|
37
45
|
```ruby
|
|
@@ -55,14 +63,14 @@ private
|
|
|
55
63
|
end
|
|
56
64
|
end
|
|
57
65
|
```
|
|
58
|
-
The subclassed state may provide
|
|
66
|
+
The subclassed state may provide !private! enter and exit methods. Any other state methods intended to be available via a call to that method on the state holder must be public. #enter and #exit will always be called appropriately during state transitions.
|
|
59
67
|
|
|
60
68
|
A state has access to methods on the state holder via #holder:
|
|
61
69
|
|
|
62
70
|
```ruby
|
|
63
71
|
holder.a_special_holder_method
|
|
64
72
|
```
|
|
65
|
-
Creation of a holder instance
|
|
73
|
+
Creation of a holder instance !must! specify the initial state class:
|
|
66
74
|
|
|
67
75
|
```ruby
|
|
68
76
|
button = Button.new(initial_state_class: Off)
|
data/lib/simplestate/version.rb
CHANGED