role_playing 0.0.5 → 0.0.6

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/README.md CHANGED
@@ -42,17 +42,18 @@ Using it is as simple as defining (usually) a context like so:
42
42
  end
43
43
 
44
44
  ## inside a context, a role can be defined
45
- ## using the class method "role"
46
- role :source_account do
45
+ ## using the class method "role", it's basically
46
+ ## the same as using class SourceAccount < RolePlaying::Role
47
+ ## but a nicer language and does the inheritance for us and -
48
+ ## YES these should be constants, not strings or symbols
49
+ role SourceAccount do
47
50
  def withdraw(amount)
48
51
  self.amount=self.amount-amount
49
52
  amount
50
53
  end
51
54
  end
52
55
 
53
- ## the #role method comes from including
54
- ## the RolePlaying::Context module
55
- role :destination_account do
56
+ role DestinationAccount do
56
57
  def deposit(amount)
57
58
  self.amount=self.amount+amount
58
59
  end
@@ -4,10 +4,13 @@ module RolePlaying
4
4
  base.extend(ClassMethods)
5
5
  end
6
6
  module ClassMethods
7
+ def const_missing(sym)
8
+ class_name = sym.to_s
9
+ end
7
10
  def role(name, parent=nil, &block)
8
11
  parent = parent || RolePlaying::Role
9
12
  klass = Class.new(parent, &block)
10
- self.const_set name.to_s.camelize, klass
13
+ const_set name, klass
11
14
  end
12
15
  end
13
16
  end
@@ -1,3 +1,3 @@
1
1
  module RolePlaying
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -36,15 +36,18 @@ class MoneyTransferring
36
36
  end
37
37
 
38
38
  ## inside a context, a role can be defined
39
- ## using the class method "role"
40
- role :source_account do
39
+ ## using the class method "role", it's basically
40
+ ## the same as using class SourceAccount < RolePlaying::Role
41
+ ## but a nicer language and does the inheritance for us and -
42
+ ## YES these should be constants, not strings or symbols
43
+ role SourceAccount do
41
44
  def withdraw(amount)
42
45
  self.amount=self.amount-amount
43
46
  amount
44
47
  end
45
48
  end
46
49
 
47
- role :destination_account do
50
+ role DestinationAccount do
48
51
  def deposit(amount)
49
52
  self.amount=self.amount+amount
50
53
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: role_playing
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: