dima-ruboss4ruby 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/Manifest.txt +2 -1
- data/lib/ruboss4ruby.rb +3 -3
- data/ruboss4ruby.gemspec +3 -3
- data/test/rails/models/task.rb +1 -3
- data/test/rails/models/user.rb +1 -3
- data/test/rails/test_active_foo.rb +3 -48
- data/test/rails/test_to_fxml.rb +3 -45
- metadata +4 -3
- data/lib/ruboss4ruby/active_record_default_methods.rb +0 -66
data/History.txt
CHANGED
data/Manifest.txt
CHANGED
@@ -50,7 +50,6 @@ generators/ruboss_yaml_scaffold/ruboss_yaml_scaffold_generator.rb
|
|
50
50
|
gpl-3.0.txt
|
51
51
|
lib/ruboss4ruby.rb
|
52
52
|
lib/ruboss4ruby/active_foo.rb
|
53
|
-
lib/ruboss4ruby/active_record_default_methods.rb
|
54
53
|
lib/ruboss4ruby/active_record_tasks.rb
|
55
54
|
lib/ruboss4ruby/configuration.rb
|
56
55
|
lib/ruboss4ruby/datamapper_foo.rb
|
@@ -110,7 +109,9 @@ test/rails/fixtures/projects.yml
|
|
110
109
|
test/rails/fixtures/simple_properties.yml
|
111
110
|
test/rails/fixtures/tasks.yml
|
112
111
|
test/rails/fixtures/users.yml
|
112
|
+
test/rails/helpers/controllers.log
|
113
113
|
test/rails/helpers/functional_test_helper.rb
|
114
|
+
test/rails/helpers/models.log
|
114
115
|
test/rails/helpers/test_helper.rb
|
115
116
|
test/rails/helpers/unit_test_helper.rb
|
116
117
|
test/rails/model.yml
|
data/lib/ruboss4ruby.rb
CHANGED
@@ -5,8 +5,8 @@
|
|
5
5
|
module Ruboss4Ruby
|
6
6
|
|
7
7
|
# :stopdoc:
|
8
|
-
VERSION = '1.1.
|
9
|
-
RUBOSS_FRAMEWORK_VERSION = '1.1.
|
8
|
+
VERSION = '1.1.2'
|
9
|
+
RUBOSS_FRAMEWORK_VERSION = '1.1.2'
|
10
10
|
LIB_DIR = File.join(File.dirname(__FILE__), 'ruboss4ruby/')
|
11
11
|
# :startdoc:
|
12
12
|
|
@@ -54,7 +54,7 @@ elsif defined?(ActionController::Base)
|
|
54
54
|
# if we are not running in Merb, try to hook up Rails
|
55
55
|
Mime::Type.register_alias "application/xml", :fxml
|
56
56
|
|
57
|
-
['active_foo', '
|
57
|
+
['active_foo', 'rails/swf_helper'].each { |lib| require Ruboss4Ruby::LIB_DIR + lib }
|
58
58
|
|
59
59
|
ActionView::Base.send :include, SWFHelper unless ActionView::Base.included_modules.include?(SWFHelper)
|
60
60
|
|
data/ruboss4ruby.gemspec
CHANGED
@@ -2,17 +2,17 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{ruboss4ruby}
|
5
|
-
s.version = "1.1.
|
5
|
+
s.version = "1.1.2"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Dima Berastau"]
|
9
|
-
s.date = %q{2009-01-
|
9
|
+
s.date = %q{2009-01-11}
|
10
10
|
s.default_executable = %q{ruboss-gen}
|
11
11
|
s.description = %q{The Ruboss Framework brings the design principles and productivity of Rails to Flex development, and makes integration with RESTful APIs as simple as possible. Here's some of the things you can do: * *Create* a complete _Adobe_ _Flex_ or _AIR_ application in less than 5 minutes. Use our lightweight Ruby-based code generation toolkit to create a fully functional CRUD application. Simply do: sudo gem install ruboss4ruby And then run: ruboss-gen -h * *Integrate* with _Ruby_ _On_ _Rails_, _Merb_ or _Sinatra_ applications that use _ActiveRecord_, _DataMapper_, _CouchRest_, _ActiveCouch_, etc. * *Communicate* between your Flex/AIR rich client and service providers using either _XML_ or _JSON_. * *Persist* your data directly in Adobe AIR's _SQLite_ database or _CouchDB_ without any additional infrastructure or intermediate servers. * *Deploy* your Ruboss application on the Google App Engine and use Google DataStore for persistence.}
|
12
12
|
s.email = %q{dima@ruboss.com}
|
13
13
|
s.executables = ["ruboss-gen"]
|
14
14
|
s.extra_rdoc_files = ["README.rdoc", "bin/ruboss-gen"]
|
15
|
-
s.files = ["History.txt", "Manifest.txt", "README.rdoc", "Rakefile", "app_generators/ruboss_app/USAGE", "app_generators/ruboss_app/ruboss_app_generator.rb", "app_generators/ruboss_app/templates/actionscript.properties", "app_generators/ruboss_app/templates/actionscriptair.properties", "app_generators/ruboss_app/templates/app.yaml.erb", "app_generators/ruboss_app/templates/default_tasks.rake", "app_generators/ruboss_app/templates/empty.txt", "app_generators/ruboss_app/templates/expressInstall.swf", "app_generators/ruboss_app/templates/flex.properties", "app_generators/ruboss_app/templates/generate.rb", "app_generators/ruboss_app/templates/html-template/AC_OETags.js", "app_generators/ruboss_app/templates/html-template/history/history.css", "app_generators/ruboss_app/templates/html-template/history/history.js", "app_generators/ruboss_app/templates/html-template/history/historyFrame.html", "app_generators/ruboss_app/templates/html-template/index.template.html", "app_generators/ruboss_app/templates/html-template/playerProductInstall.swf", "app_generators/ruboss_app/templates/index.html.erb", "app_generators/ruboss_app/templates/index.yaml", "app_generators/ruboss_app/templates/mainair-app.xml", "app_generators/ruboss_app/templates/mainapp-config.xml", "app_generators/ruboss_app/templates/mainapp.mxml", "app_generators/ruboss_app/templates/project-textmate.erb", "app_generators/ruboss_app/templates/project.properties", "app_generators/ruboss_app/templates/projectair.properties", "app_generators/ruboss_app/templates/swfobject.js", "bin/ruboss-gen", "generators/ruboss_config/USAGE", "generators/ruboss_config/ruboss_config_generator.rb", "generators/ruboss_controller/USAGE", "generators/ruboss_controller/ruboss_controller_generator.rb", "generators/ruboss_controller/templates/assist.py", "generators/ruboss_controller/templates/controller.as.erb", "generators/ruboss_controller/templates/restful.py", "generators/ruboss_main_app/USAGE", "generators/ruboss_main_app/ruboss_main_app_generator.rb", "generators/ruboss_main_app/templates/main.py.erb", "generators/ruboss_main_app/templates/mainapp.mxml", "generators/ruboss_scaffold/USAGE", "generators/ruboss_scaffold/ruboss_scaffold_generator.rb", "generators/ruboss_scaffold/templates/component.mxml.erb", "generators/ruboss_scaffold/templates/controller.py.erb", "generators/ruboss_scaffold/templates/model.as.erb", "generators/ruboss_scaffold/templates/model.py.erb", "generators/ruboss_yaml_scaffold/USAGE", "generators/ruboss_yaml_scaffold/ruboss_yaml_scaffold_generator.rb", "gpl-3.0.txt", "lib/ruboss4ruby.rb", "lib/ruboss4ruby/active_foo.rb", "lib/ruboss4ruby/
|
15
|
+
s.files = ["History.txt", "Manifest.txt", "README.rdoc", "Rakefile", "app_generators/ruboss_app/USAGE", "app_generators/ruboss_app/ruboss_app_generator.rb", "app_generators/ruboss_app/templates/actionscript.properties", "app_generators/ruboss_app/templates/actionscriptair.properties", "app_generators/ruboss_app/templates/app.yaml.erb", "app_generators/ruboss_app/templates/default_tasks.rake", "app_generators/ruboss_app/templates/empty.txt", "app_generators/ruboss_app/templates/expressInstall.swf", "app_generators/ruboss_app/templates/flex.properties", "app_generators/ruboss_app/templates/generate.rb", "app_generators/ruboss_app/templates/html-template/AC_OETags.js", "app_generators/ruboss_app/templates/html-template/history/history.css", "app_generators/ruboss_app/templates/html-template/history/history.js", "app_generators/ruboss_app/templates/html-template/history/historyFrame.html", "app_generators/ruboss_app/templates/html-template/index.template.html", "app_generators/ruboss_app/templates/html-template/playerProductInstall.swf", "app_generators/ruboss_app/templates/index.html.erb", "app_generators/ruboss_app/templates/index.yaml", "app_generators/ruboss_app/templates/mainair-app.xml", "app_generators/ruboss_app/templates/mainapp-config.xml", "app_generators/ruboss_app/templates/mainapp.mxml", "app_generators/ruboss_app/templates/project-textmate.erb", "app_generators/ruboss_app/templates/project.properties", "app_generators/ruboss_app/templates/projectair.properties", "app_generators/ruboss_app/templates/swfobject.js", "bin/ruboss-gen", "generators/ruboss_config/USAGE", "generators/ruboss_config/ruboss_config_generator.rb", "generators/ruboss_controller/USAGE", "generators/ruboss_controller/ruboss_controller_generator.rb", "generators/ruboss_controller/templates/assist.py", "generators/ruboss_controller/templates/controller.as.erb", "generators/ruboss_controller/templates/restful.py", "generators/ruboss_main_app/USAGE", "generators/ruboss_main_app/ruboss_main_app_generator.rb", "generators/ruboss_main_app/templates/main.py.erb", "generators/ruboss_main_app/templates/mainapp.mxml", "generators/ruboss_scaffold/USAGE", "generators/ruboss_scaffold/ruboss_scaffold_generator.rb", "generators/ruboss_scaffold/templates/component.mxml.erb", "generators/ruboss_scaffold/templates/controller.py.erb", "generators/ruboss_scaffold/templates/model.as.erb", "generators/ruboss_scaffold/templates/model.py.erb", "generators/ruboss_yaml_scaffold/USAGE", "generators/ruboss_yaml_scaffold/ruboss_yaml_scaffold_generator.rb", "gpl-3.0.txt", "lib/ruboss4ruby.rb", "lib/ruboss4ruby/active_foo.rb", "lib/ruboss4ruby/active_record_tasks.rb", "lib/ruboss4ruby/configuration.rb", "lib/ruboss4ruby/datamapper_foo.rb", "lib/ruboss4ruby/rails/recipes.rb", "lib/ruboss4ruby/rails/swf_helper.rb", "lib/ruboss4ruby/tasks.rb", "rails_generators/ruboss_config/USAGE", "rails_generators/ruboss_config/ruboss_config_generator.rb", "rails_generators/ruboss_config/templates/actionscript.properties", "rails_generators/ruboss_config/templates/actionscriptair.properties", "rails_generators/ruboss_config/templates/expressInstall.swf", "rails_generators/ruboss_config/templates/flex.properties", "rails_generators/ruboss_config/templates/html-template/AC_OETags.js", "rails_generators/ruboss_config/templates/html-template/history/history.css", "rails_generators/ruboss_config/templates/html-template/history/history.js", "rails_generators/ruboss_config/templates/html-template/history/historyFrame.html", "rails_generators/ruboss_config/templates/html-template/index.template.html", "rails_generators/ruboss_config/templates/html-template/playerProductInstall.swf", "rails_generators/ruboss_config/templates/index.html.erb", "rails_generators/ruboss_config/templates/mainair-app.xml", "rails_generators/ruboss_config/templates/mainapp-config.xml", "rails_generators/ruboss_config/templates/mainapp.mxml", "rails_generators/ruboss_config/templates/project-textmate.erb", "rails_generators/ruboss_config/templates/project.properties", "rails_generators/ruboss_config/templates/projectair.properties", "rails_generators/ruboss_config/templates/ruboss.yml", "rails_generators/ruboss_config/templates/ruboss_tasks.rake", "rails_generators/ruboss_config/templates/swfobject.js", "rails_generators/ruboss_controller/USAGE", "rails_generators/ruboss_controller/ruboss_controller_generator.rb", "rails_generators/ruboss_controller/templates/controller.as.erb", "rails_generators/ruboss_scaffold/USAGE", "rails_generators/ruboss_scaffold/ruboss_scaffold_generator.rb", "rails_generators/ruboss_scaffold/templates/component.mxml.erb", "rails_generators/ruboss_scaffold/templates/controller.rb.erb", "rails_generators/ruboss_scaffold/templates/fixtures.yml.erb", "rails_generators/ruboss_scaffold/templates/migration.rb.erb", "rails_generators/ruboss_scaffold/templates/model.as.erb", "rails_generators/ruboss_scaffold/templates/model.rb.erb", "rails_generators/ruboss_yaml_scaffold/USAGE", "rails_generators/ruboss_yaml_scaffold/ruboss_yaml_scaffold_generator.rb", "rcl-1.0.txt", "rdoc/generators/template/html/jamis.rb", "ruboss4ruby.gemspec", "spec/ruboss4ruby_spec.rb", "spec/spec_helper.rb", "test/rails/controllers/application.rb", "test/rails/controllers/locations_controller.rb", "test/rails/controllers/notes_controller.rb", "test/rails/controllers/projects_controller.rb", "test/rails/controllers/tasks_controller.rb", "test/rails/controllers/users_controller.rb", "test/rails/database.yml", "test/rails/fixtures/locations.yml", "test/rails/fixtures/notes.yml", "test/rails/fixtures/projects.yml", "test/rails/fixtures/simple_properties.yml", "test/rails/fixtures/tasks.yml", "test/rails/fixtures/users.yml", "test/rails/helpers/controllers.log", "test/rails/helpers/functional_test_helper.rb", "test/rails/helpers/models.log", "test/rails/helpers/test_helper.rb", "test/rails/helpers/unit_test_helper.rb", "test/rails/model.yml", "test/rails/models/location.rb", "test/rails/models/note.rb", "test/rails/models/project.rb", "test/rails/models/simple_property.rb", "test/rails/models/task.rb", "test/rails/models/user.rb", "test/rails/playing_around_in_a_console.txt", "test/rails/schema.rb", "test/rails/test.swf", "test/rails/test_active_foo.rb", "test/rails/test_ruboss_rails_integration_functional.rb", "test/rails/test_to_fxml.rb", "test/rails/test_to_json.rb", "test/rails/views/notes/empty_params_action.html.erb", "test/rails/views/notes/index.html.erb"]
|
16
16
|
s.has_rdoc = true
|
17
17
|
s.homepage = %q{http://github.com/dima/ruboss4ruby/wikis}
|
18
18
|
s.rdoc_options = ["--main", "README.rdoc"]
|
data/test/rails/models/task.rb
CHANGED
data/test/rails/models/user.rb
CHANGED
@@ -15,7 +15,7 @@ class ActiveFooTest < Test::Unit::TestCase
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def test_task_fxml_has_default_method
|
18
|
-
set_response_to tasks(:haydn).to_fxml
|
18
|
+
set_response_to tasks(:haydn).to_fxml(:methods => :is_active)
|
19
19
|
assert_xml_select 'task is_active'
|
20
20
|
end
|
21
21
|
|
@@ -25,57 +25,12 @@ class ActiveFooTest < Test::Unit::TestCase
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def test_user_fxml_has_nothing_to_do_method
|
28
|
-
set_response_to users(:ludwig).to_fxml
|
28
|
+
set_response_to users(:ludwig).to_fxml(:methods => :has_nothing_to_do)
|
29
29
|
assert_xml_select 'user has_nothing_to_do'
|
30
30
|
end
|
31
31
|
|
32
32
|
def test_user_fxml_includes_default_method_from_task
|
33
|
-
set_response_to users(:ludwig).to_fxml(:include => :tasks)
|
33
|
+
set_response_to users(:ludwig).to_fxml(:methods => :is_active, :include => :tasks)
|
34
34
|
assert_xml_select 'user tasks task is_active'
|
35
35
|
end
|
36
|
-
#
|
37
|
-
# def test_projects_fxml_includes_tasks
|
38
|
-
# set_response_to projects(:music).to_fxml
|
39
|
-
# assert_xml_select 'project tasks task'
|
40
|
-
# end
|
41
|
-
#
|
42
|
-
# def test_projects_with_user_included_as_symbol
|
43
|
-
# set_response_to projects(:music).to_fxml(:include => :user)
|
44
|
-
# assert_xml_select 'project user'
|
45
|
-
# end
|
46
|
-
#
|
47
|
-
# def test_includes_as_hash_returns_hashes
|
48
|
-
# assert_equal Hash.new, User.includes_as_hash
|
49
|
-
# assert_equal ({:one => 1, :two => 2}), User.includes_as_hash({:one => 1, :two => 2})
|
50
|
-
# assert_equal ({:test => {}}), User.includes_as_hash(:test)
|
51
|
-
# assert_equal ({:test1 => {}, :test2 => {}}), User.includes_as_hash([:test1, :test2])
|
52
|
-
# end
|
53
|
-
#
|
54
|
-
# def test_validates_length_of_validates_length
|
55
|
-
# assert_nothing_raised do
|
56
|
-
# @shakespeare.login = 'william_shakespeare'
|
57
|
-
# @shakespeare.save
|
58
|
-
# assert !@shakespeare.errors.empty?
|
59
|
-
# end
|
60
|
-
# @shakespeare.login = 'william'
|
61
|
-
# @shakespeare.save
|
62
|
-
# assert @shakespeare.errors.empty?
|
63
|
-
# end
|
64
|
-
#
|
65
|
-
# def test_you_can_do_to_fxml_with_validates_length
|
66
|
-
# assert_nothing_raised do
|
67
|
-
# @shakespeare.to_fxml
|
68
|
-
# end
|
69
|
-
# end
|
70
|
-
#
|
71
|
-
# def test_array_of_users_includes_default_fxml_includes
|
72
|
-
# set_response_to User.find(:all).to_fxml
|
73
|
-
# assert_xml_select 'users user tasks task'
|
74
|
-
# end
|
75
|
-
#
|
76
|
-
# def test_to_fxml_should_take_a_block
|
77
|
-
# set_response_to users(:ludwig).to_fxml {|xml| xml.test 42}
|
78
|
-
# assert_xml_select 'test', '42'
|
79
|
-
# end
|
80
|
-
|
81
36
|
end
|
data/test/rails/test_to_fxml.rb
CHANGED
@@ -21,57 +21,15 @@ class ToFxmlTest < Test::Unit::TestCase
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def test_default_xml_methods_on_user_are_included_in_fxml
|
24
|
-
set_response_to users(:ludwig).to_fxml
|
24
|
+
set_response_to users(:ludwig).to_fxml(:methods => [:has_nothing_to_do, :full_name])
|
25
25
|
assert_xml_select 'user full_name', 'Ludwig van Beethoven'
|
26
26
|
assert_xml_select 'user has_nothing_to_do'
|
27
27
|
end
|
28
28
|
|
29
29
|
def test_default_xml_methods_on_user_are_included_in_fxml_if_you_call_it_twice
|
30
|
-
set_response_to users(:ludwig).to_fxml
|
31
|
-
set_response_to users(:ludwig).to_fxml
|
30
|
+
set_response_to users(:ludwig).to_fxml(:methods => [:has_nothing_to_do, :full_name])
|
31
|
+
set_response_to users(:ludwig).to_fxml(:methods => [:has_nothing_to_do, :full_name])
|
32
32
|
assert_xml_select 'user full_name', 'Ludwig van Beethoven'
|
33
33
|
assert_xml_select 'user has_nothing_to_do'
|
34
34
|
end
|
35
|
-
|
36
|
-
def test_default_xml_methods_exists
|
37
|
-
assert User.respond_to?(:default_methods_array)
|
38
|
-
assert_equal [:full_name, :has_nothing_to_do], User.default_methods_array
|
39
|
-
end
|
40
|
-
#
|
41
|
-
# def test_default_xml_methods_on_dependencies
|
42
|
-
# t = users(:ludwig).tasks.first
|
43
|
-
# assert t.class.respond_to?(:default_xml_methods_array)
|
44
|
-
# assert_equal [:is_active], t.class.default_xml_methods_array
|
45
|
-
# end
|
46
|
-
#
|
47
|
-
# def test_default_xml_methods_are_included_in_includes
|
48
|
-
# set_response_to users(:ludwig).to_fxml(:include => :tasks)
|
49
|
-
# assert_xml_select 'tasks task is_active'
|
50
|
-
# end
|
51
|
-
#
|
52
|
-
# def test_model_without_default_xml_methods_still_works
|
53
|
-
# assert_nothing_raised{ locations(:vienna).to_fxml }
|
54
|
-
# end
|
55
|
-
#
|
56
|
-
# def test_user_with_non_default_methods_in_to_xml
|
57
|
-
# set_response_to users(:ludwig).to_fxml(:methods => :email_host)
|
58
|
-
# assert_xml_select 'user email_host', 'vienna.de'
|
59
|
-
# assert_xml_select 'user full_name'
|
60
|
-
# end
|
61
|
-
#
|
62
|
-
# def test_model_with_default_xml_includes
|
63
|
-
# set_response_to users(:ludwig).to_fxml
|
64
|
-
# assert_xml_select 'user tasks task'
|
65
|
-
# end
|
66
|
-
#
|
67
|
-
# def test_simple_properies
|
68
|
-
# puts simple_properties
|
69
|
-
# end
|
70
|
-
|
71
|
-
# Test type=.... stuff for has_many, booleans, integers, dates, date-times
|
72
|
-
|
73
|
-
# Test empty arrays
|
74
|
-
|
75
|
-
# Test options[:except]
|
76
|
-
|
77
35
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dima-ruboss4ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dima Berastau
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-01-
|
12
|
+
date: 2009-01-11 00:00:00 -08:00
|
13
13
|
default_executable: ruboss-gen
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -101,7 +101,6 @@ files:
|
|
101
101
|
- gpl-3.0.txt
|
102
102
|
- lib/ruboss4ruby.rb
|
103
103
|
- lib/ruboss4ruby/active_foo.rb
|
104
|
-
- lib/ruboss4ruby/active_record_default_methods.rb
|
105
104
|
- lib/ruboss4ruby/active_record_tasks.rb
|
106
105
|
- lib/ruboss4ruby/configuration.rb
|
107
106
|
- lib/ruboss4ruby/datamapper_foo.rb
|
@@ -161,7 +160,9 @@ files:
|
|
161
160
|
- test/rails/fixtures/simple_properties.yml
|
162
161
|
- test/rails/fixtures/tasks.yml
|
163
162
|
- test/rails/fixtures/users.yml
|
163
|
+
- test/rails/helpers/controllers.log
|
164
164
|
- test/rails/helpers/functional_test_helper.rb
|
165
|
+
- test/rails/helpers/models.log
|
165
166
|
- test/rails/helpers/test_helper.rb
|
166
167
|
- test/rails/helpers/unit_test_helper.rb
|
167
168
|
- test/rails/model.yml
|
@@ -1,66 +0,0 @@
|
|
1
|
-
module ActiveRecord
|
2
|
-
#
|
3
|
-
# We also add support for serializing model methods along the lines of:
|
4
|
-
#
|
5
|
-
# class Project < ActiveRecord::Base
|
6
|
-
# default_methods :foobar
|
7
|
-
#
|
8
|
-
# def foobar
|
9
|
-
# 'foobar'
|
10
|
-
# end
|
11
|
-
# end
|
12
|
-
#
|
13
|
-
# When you do +to_fxml+ on this model method foobar will be automatically
|
14
|
-
# serialized as a simple attribute
|
15
|
-
class Base
|
16
|
-
class << self
|
17
|
-
|
18
|
-
# default methods hook
|
19
|
-
def default_methods(*args)
|
20
|
-
methods = *args.dup
|
21
|
-
module_eval <<-END
|
22
|
-
def self.default_methods_array
|
23
|
-
return [#{methods.inspect}].flatten
|
24
|
-
end
|
25
|
-
END
|
26
|
-
end
|
27
|
-
|
28
|
-
# default methods hook
|
29
|
-
def defaults_hash(already_included = [], ignore_default_methods = nil)
|
30
|
-
defaults_hash = {:include => {}}
|
31
|
-
unless ignore_default_methods
|
32
|
-
defaults_hash[:methods] = self.default_methods_array if self.respond_to?(:default_methods_array)
|
33
|
-
end
|
34
|
-
defaults_hash
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
# Flex-friendly serialization patches
|
40
|
-
module Serialization
|
41
|
-
|
42
|
-
alias_method :xml_defaults_old_to_xml, :to_xml unless method_defined?(:xml_defaults_old_to_xml)
|
43
|
-
|
44
|
-
alias_method :json_defaults_old_to_json, :to_json unless method_defined?(:json_defaults_old_to_json)
|
45
|
-
|
46
|
-
# adds support for default_methods to standard +to_xml+
|
47
|
-
def to_xml(options = {}, &block)
|
48
|
-
unless options[:ignore_defaults]
|
49
|
-
unless options[:ignore_default_methods]
|
50
|
-
options[:methods] = [options[:methods] || []].flatten + (self.class.defaults_hash[:methods] || [])
|
51
|
-
end
|
52
|
-
end
|
53
|
-
xml_defaults_old_to_xml(options, &block)
|
54
|
-
end
|
55
|
-
|
56
|
-
# adds support for default_methods to standard +to_json+
|
57
|
-
def to_json(options = {}, &block)
|
58
|
-
unless options[:ignore_defaults]
|
59
|
-
unless options[:ignore_default_methods]
|
60
|
-
options[:methods] = [options[:methods] || []].flatten + (self.class.defaults_hash[:methods] || [])
|
61
|
-
end
|
62
|
-
end
|
63
|
-
json_defaults_old_to_json(options, &block)
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|