model_xml 1.0.0 → 1.0.1
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/.gitignore +2 -1
- data/README.md +5 -2
- data/model_xml.gemspec +14 -0
- metadata +4 -3
data/.gitignore
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
*.sw*
|
1
|
+
*.sw*
|
2
|
+
model_xml-1.0.0.gem
|
data/README.md
CHANGED
@@ -35,7 +35,7 @@ Note that (unlike ActiveRecords's to_xml) the field names can be any method in y
|
|
35
35
|
model_xml :full_name, :dob
|
36
36
|
|
37
37
|
def full_name
|
38
|
-
"#{first_name} {
|
38
|
+
"#{first_name} #{last_name}"
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
@@ -65,7 +65,7 @@ For more complicated setups, you can use block notation like this:
|
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
|
-
|
68
|
+
For conditional data sets, you can declare named blocks using block notation like this:
|
69
69
|
|
70
70
|
class User < ActiveRecord::Base
|
71
71
|
model_xml :first_name, :last_name
|
@@ -93,6 +93,9 @@ but can be included explicitly - so user.to_xml(:personal_details => true) gives
|
|
93
93
|
<last_logged_in>2012-04-10</last_logged_in>
|
94
94
|
</user>
|
95
95
|
|
96
|
+
Finally, if any of the field names return objects which themselves respond to to_xml, then their xml representations will be embedded. So if you use the name of an active record association, then the child(ren) should be embedded in the xml as you'd expect.
|
97
|
+
|
98
|
+
|
96
99
|
Source
|
97
100
|
======
|
98
101
|
|
data/model_xml.gemspec
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = "model_xml"
|
3
|
+
s.version = '1.0.1'
|
4
|
+
s.authors = "Rob Anderson"
|
5
|
+
s.email = "rob.anderson@paymentcardsolutions.co.uk"
|
6
|
+
s.summary = "Ruby object to xml converter"
|
7
|
+
s.description = "Simple replacement for ActiveRecord's default to_xml"
|
8
|
+
|
9
|
+
s.add_dependency 'builder', '>= 2.1.2'
|
10
|
+
s.add_dependency 'nokogiri', '>= 1.4.2'
|
11
|
+
|
12
|
+
s.files = `git ls-files`.split("\n")
|
13
|
+
s.require_path = "lib"
|
14
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: model_xml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 1
|
10
|
+
version: 1.0.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Rob Anderson
|
@@ -63,6 +63,7 @@ files:
|
|
63
63
|
- lib/model_xml.rb
|
64
64
|
- lib/model_xml/block_parser.rb
|
65
65
|
- lib/model_xml/generator.rb
|
66
|
+
- model_xml.gemspec
|
66
67
|
- test/test_block_parser.rb
|
67
68
|
- test/test_model_xml.rb
|
68
69
|
homepage:
|