unhappymapper 0.4.4 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -222,12 +222,12 @@ Well if we only going to parse country, on it's own, we would likely create a cl
222
222
  tag 'country'
223
223
 
224
224
  attribute :code, String
225
- text_node :name, String
225
+ content :name, String
226
226
  end
227
227
 
228
- We are utilizing an `attribute` declaration and a new declaration called `text_node`.
228
+ We are utilizing an `attribute` declaration and a new declaration called `content`.
229
229
 
230
- * `text_node` is used when you want the text contained within the element
230
+ * `content` is used when you want the text contained within the element
231
231
 
232
232
  Awesome, now if we were to redeclare our `Address` class we would use our new `Country` class.
233
233
 
@@ -107,7 +107,7 @@ module HappyMapper
107
107
  def elements
108
108
  @elements[to_s] || []
109
109
  end
110
-
110
+
111
111
  #
112
112
  # The value stored in the text node of the current element.
113
113
  #
@@ -117,16 +117,16 @@ module HappyMapper
117
117
  #
118
118
  # # definition of the 'firstName' text node within the class
119
119
  #
120
- # text_node :first_name, String
120
+ # content :first_name, String
121
121
  #
122
122
  # @param [Symbol] name the name of the accessor that is created
123
123
  # @param [String,Class] type the class name of the name of the class whcih
124
124
  # the object will be converted upon parsing
125
125
  # @param [Hash] options additional parameters to send to the relationship
126
126
  #
127
- def text_node(name, type, options={})
128
- @text_node = TextNode.new(name, type, options)
129
- attr_accessor @text_node.method_name.intern
127
+ def content(name, type, options={})
128
+ @content = TextNode.new(name, type, options)
129
+ attr_accessor @content.method_name.intern
130
130
  end
131
131
 
132
132
  #
@@ -315,8 +315,8 @@ module HappyMapper
315
315
  obj.send("#{elem.method_name}=",elem.from_xml_node(n, namespace, namespaces))
316
316
  end
317
317
 
318
- if @text_node
319
- obj.send("#{@text_node.method_name}=",@text_node.from_xml_node(n, namespace, namespaces))
318
+ if @content
319
+ obj.send("#{@content.method_name}=",@content.from_xml_node(n, namespace, namespaces))
320
320
  end
321
321
 
322
322
  # If the HappyMapper class has the method #xml_value=,
@@ -481,16 +481,16 @@ module HappyMapper
481
481
 
482
482
 
483
483
  #
484
- # When a text_node has been defined we add the resulting value
484
+ # When a content has been defined we add the resulting value
485
485
  # the output xml
486
486
  #
487
- if text_node = self.class.instance_variable_get('@text_node')
487
+ if content = self.class.instance_variable_get('@content')
488
488
 
489
- unless text_node.options[:read_only]
490
- text_accessor = text_node.tag || text_node.name
489
+ unless content.options[:read_only]
490
+ text_accessor = content.tag || content.name
491
491
  value = send(text_accessor)
492
492
 
493
- if on_save_action = text_node.options[:on_save]
493
+ if on_save_action = content.options[:on_save]
494
494
  if on_save_action.is_a?(Proc)
495
495
  value = on_save_action.call(value)
496
496
  elsif respond_to?(on_save_action)
@@ -304,7 +304,7 @@ class Country
304
304
  include HappyMapper
305
305
 
306
306
  attribute :code, String
307
- text_node :name, String
307
+ content :name, String
308
308
  end
309
309
 
310
310
  class Address
@@ -81,7 +81,7 @@ module ToXML
81
81
  #
82
82
  class Description
83
83
  include HappyMapper
84
- text_node :description, String
84
+ content :description, String
85
85
  attribute :category, String, :tag => 'category'
86
86
  attribute :rating, String, :tag => 'rating', :state_when_nil => true
87
87
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unhappymapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
4
+ version: 0.5.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -18,7 +18,7 @@ date: 2011-08-22 00:00:00.000000000Z
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency
20
20
  name: nokogiri
21
- requirement: &70120458309660 !ruby/object:Gem::Requirement
21
+ requirement: &70125244720920 !ruby/object:Gem::Requirement
22
22
  none: false
23
23
  requirements:
24
24
  - - ~>
@@ -26,10 +26,10 @@ dependencies:
26
26
  version: '1.4'
27
27
  type: :runtime
28
28
  prerelease: false
29
- version_requirements: *70120458309660
29
+ version_requirements: *70125244720920
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: rspec
32
- requirement: &70120458305740 !ruby/object:Gem::Requirement
32
+ requirement: &70125244720240 !ruby/object:Gem::Requirement
33
33
  none: false
34
34
  requirements:
35
35
  - - ~>
@@ -37,7 +37,7 @@ dependencies:
37
37
  version: 1.3.0
38
38
  type: :development
39
39
  prerelease: false
40
- version_requirements: *70120458305740
40
+ version_requirements: *70125244720240
41
41
  description: Object to XML Mapping Library, using Nokogiri (fork from John Nunemaker's
42
42
  Happymapper)
43
43
  email: franklin.webber@gmail.com