mingle_event_changes 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -15,7 +15,28 @@ module MingleEventChanges
15
15
  class CardTypeValue
16
16
  include SAXMachine
17
17
  element :name
18
- element :card_type, :value => :url, :as => :url
18
+ attribute :url
19
+ end
20
+
21
+ class CardValue
22
+ include SAXMachine
23
+ element :number
24
+ attribute :url
25
+ end
26
+
27
+ class UserValue
28
+ include SAXMachine
29
+ element :name
30
+ element :login
31
+ attribute :url
32
+ end
33
+
34
+ class Value
35
+ include SAXMachine
36
+ element :card_type, :class => CardTypeValue
37
+ element :user, :class => UserValue
38
+ element :card, :class => CardValue
39
+ value :text
19
40
  end
20
41
 
21
42
  class Change
@@ -35,13 +56,43 @@ module MingleEventChanges
35
56
 
36
57
  class PropertyChange < Change
37
58
  element :property_definition, :class => PropertyDefinition
38
- element :old_value
39
- element :new_value
59
+
60
+ element :old_value, :as => :old_value_subject, :class => Value
61
+ element :new_value, :as => :new_value_subject, :class => Value
62
+
63
+ def old_value
64
+ value(old_value_subject)
65
+ end
66
+
67
+ def new_value
68
+ value(new_value_subject)
69
+ end
70
+
71
+ def value(subject)
72
+ case property_definition.data_type
73
+ when 'user'
74
+ subject.user
75
+ when 'card'
76
+ subject.card
77
+ else
78
+ if r = subject.text
79
+ r.empty? ? nil : r
80
+ end
81
+ end
82
+ end
40
83
  end
41
84
 
42
85
  class CardTypeChange < Change
43
- element :old_value, :class => CardTypeValue
44
- element :new_value, :class => CardTypeValue
86
+ element :old_value, :as => :old_value_subject, :class => Value
87
+ element :new_value, :as => :new_value_subject, :class => Value
88
+
89
+ def old_value
90
+ old_value_subject.card_type
91
+ end
92
+
93
+ def new_value
94
+ new_value_subject.card_type
95
+ end
45
96
  end
46
97
 
47
98
  class TagChange < Change
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mingle_event_changes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: