jstorimer-deep-test 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -0
- data/CHANGELOG +47 -0
- data/README.rdoc +199 -0
- data/Rakefile +150 -0
- data/TODO +4 -0
- data/VERSION +1 -0
- data/infrastructure/dynamic_teardown.rb +22 -0
- data/infrastructure/fake_deadlock_error.rb +12 -0
- data/infrastructure/load.rb +11 -0
- data/infrastructure/test_central_command.rb +15 -0
- data/infrastructure/test_exception.rb +7 -0
- data/infrastructure/test_factory.rb +74 -0
- data/infrastructure/test_logger.rb +11 -0
- data/infrastructure/test_operator.rb +15 -0
- data/infrastructure/test_result.rb +15 -0
- data/infrastructure/thread_agent.rb +21 -0
- data/infrastructure/timewarp/Rakefile +14 -0
- data/infrastructure/timewarp/lib/timewarp.rb +21 -0
- data/infrastructure/timewarp/test/timewarp_test.rb +45 -0
- data/lib/deep_test/agent.rb +108 -0
- data/lib/deep_test/central_command.rb +165 -0
- data/lib/deep_test/cpu_info.rb +22 -0
- data/lib/deep_test/database/mysql_setup_listener.rb +112 -0
- data/lib/deep_test/database/setup_listener.rb +116 -0
- data/lib/deep_test/deadlock_detector.rb +7 -0
- data/lib/deep_test/demon.rb +25 -0
- data/lib/deep_test/distributed/beachhead.rb +104 -0
- data/lib/deep_test/distributed/dispatch_controller.rb +60 -0
- data/lib/deep_test/distributed/establish_beachhead.rb +19 -0
- data/lib/deep_test/distributed/filename_resolver.rb +40 -0
- data/lib/deep_test/distributed/landing_fleet.rb +30 -0
- data/lib/deep_test/distributed/landing_ship.rb +60 -0
- data/lib/deep_test/distributed/remote_deployment.rb +56 -0
- data/lib/deep_test/distributed/rsync.rb +50 -0
- data/lib/deep_test/distributed/shell_environment.rb +50 -0
- data/lib/deep_test/distributed/ssh_client_connection_info.rb +14 -0
- data/lib/deep_test/extensions/object_extension.rb +40 -0
- data/lib/deep_test/failure_message.rb +19 -0
- data/lib/deep_test/lib_root.rb +4 -0
- data/lib/deep_test/listener_list.rb +17 -0
- data/lib/deep_test/local_deployment.rb +46 -0
- data/lib/deep_test/logger.rb +32 -0
- data/lib/deep_test/main.rb +41 -0
- data/lib/deep_test/marshallable_exception_wrapper.rb +44 -0
- data/lib/deep_test/metrics/data.rb +34 -0
- data/lib/deep_test/metrics/measurement.rb +39 -0
- data/lib/deep_test/null_listener.rb +62 -0
- data/lib/deep_test/options.rb +113 -0
- data/lib/deep_test/proxy_io.rb +77 -0
- data/lib/deep_test/rake_tasks.rb +13 -0
- data/lib/deep_test/result_reader.rb +40 -0
- data/lib/deep_test/rspec_detector.rb +21 -0
- data/lib/deep_test/spec/extensions/example_group_methods.rb +64 -0
- data/lib/deep_test/spec/extensions/example_methods.rb +52 -0
- data/lib/deep_test/spec/extensions/options.rb +43 -0
- data/lib/deep_test/spec/extensions/spec_task.rb +21 -0
- data/lib/deep_test/spec/runner.rb +72 -0
- data/lib/deep_test/spec/work_result.rb +35 -0
- data/lib/deep_test/spec/work_unit.rb +59 -0
- data/lib/deep_test/spec.rb +17 -0
- data/lib/deep_test/test/extensions/error.rb +14 -0
- data/lib/deep_test/test/run_test_suite.rb +5 -0
- data/lib/deep_test/test/runner.rb +24 -0
- data/lib/deep_test/test/supervised_test_suite.rb +48 -0
- data/lib/deep_test/test/work_result.rb +35 -0
- data/lib/deep_test/test/work_unit.rb +40 -0
- data/lib/deep_test/test.rb +10 -0
- data/lib/deep_test/test_task.rb +47 -0
- data/lib/deep_test/ui/console.rb +74 -0
- data/lib/deep_test/ui/null.rb +17 -0
- data/lib/deep_test/warlock.rb +146 -0
- data/lib/deep_test.rb +78 -0
- data/lib/telegraph/ack_sequence.rb +14 -0
- data/lib/telegraph/logging.rb +20 -0
- data/lib/telegraph/message.rb +39 -0
- data/lib/telegraph/operator.rb +47 -0
- data/lib/telegraph/switchboard.rb +57 -0
- data/lib/telegraph/wire.rb +73 -0
- data/lib/telegraph.rb +29 -0
- data/negative_acceptance_tests/dying_spec.rb +13 -0
- data/negative_acceptance_tests/dying_test.rb +13 -0
- data/negative_acceptance_tests/failing_spec.rb +9 -0
- data/negative_acceptance_tests/failing_test.rb +9 -0
- data/negative_acceptance_tests/kill_agent_one_on_start_work.rb +16 -0
- data/negative_acceptance_tests/passing_spec.rb +10 -0
- data/negative_acceptance_tests/passing_test.rb +12 -0
- data/negative_acceptance_tests/tasks.rake +87 -0
- data/negative_acceptance_tests/tests.rb +60 -0
- data/sample_rails_project/README +182 -0
- data/sample_rails_project/Rakefile +10 -0
- data/sample_rails_project/app/controllers/application.rb +7 -0
- data/sample_rails_project/app/controllers/people_controller.rb +2 -0
- data/sample_rails_project/app/helpers/application_helper.rb +3 -0
- data/sample_rails_project/app/helpers/people_helper.rb +7 -0
- data/sample_rails_project/app/models/person.rb +2 -0
- data/sample_rails_project/config/boot.rb +45 -0
- data/sample_rails_project/config/database.yml +29 -0
- data/sample_rails_project/config/environment.rb +60 -0
- data/sample_rails_project/config/environments/development.rb +21 -0
- data/sample_rails_project/config/environments/production.rb +18 -0
- data/sample_rails_project/config/environments/test.rb +19 -0
- data/sample_rails_project/config/routes.rb +23 -0
- data/sample_rails_project/db/.gitignore +2 -0
- data/sample_rails_project/db/migrate/001_create_people.rb +11 -0
- data/sample_rails_project/db/schema.rb +11 -0
- data/sample_rails_project/deep_test.rb +34 -0
- data/sample_rails_project/doc/README_FOR_APP +2 -0
- data/sample_rails_project/lib/foreign_host_agent_simulation_listener.rb +16 -0
- data/sample_rails_project/lib/tasks/create.sql +6 -0
- data/sample_rails_project/lib/tasks/db.rake +16 -0
- data/sample_rails_project/lib/tasks/deep_test.rake +27 -0
- data/sample_rails_project/log/.gitignore +2 -0
- data/sample_rails_project/public/.htaccess +40 -0
- data/sample_rails_project/public/404.html +30 -0
- data/sample_rails_project/public/500.html +30 -0
- data/sample_rails_project/public/dispatch.cgi +10 -0
- data/sample_rails_project/public/dispatch.fcgi +24 -0
- data/sample_rails_project/public/dispatch.rb +10 -0
- data/sample_rails_project/public/favicon.ico +0 -0
- data/sample_rails_project/public/images/rails.png +0 -0
- data/sample_rails_project/public/index.html +277 -0
- data/sample_rails_project/public/javascripts/application.js +2 -0
- data/sample_rails_project/public/javascripts/controls.js +833 -0
- data/sample_rails_project/public/javascripts/dragdrop.js +942 -0
- data/sample_rails_project/public/javascripts/effects.js +1088 -0
- data/sample_rails_project/public/javascripts/prototype.js +2515 -0
- data/sample_rails_project/public/robots.txt +1 -0
- data/sample_rails_project/script/about +3 -0
- data/sample_rails_project/script/breakpointer +3 -0
- data/sample_rails_project/script/console +3 -0
- data/sample_rails_project/script/destroy +3 -0
- data/sample_rails_project/script/generate +3 -0
- data/sample_rails_project/script/performance/benchmarker +3 -0
- data/sample_rails_project/script/performance/profiler +3 -0
- data/sample_rails_project/script/plugin +3 -0
- data/sample_rails_project/script/process/inspector +3 -0
- data/sample_rails_project/script/process/reaper +3 -0
- data/sample_rails_project/script/process/spawner +3 -0
- data/sample_rails_project/script/runner +3 -0
- data/sample_rails_project/script/server +3 -0
- data/sample_rails_project/script/spec +4 -0
- data/sample_rails_project/script/spec_server +102 -0
- data/sample_rails_project/spec/controllers/people_controller_spec.rb +10 -0
- data/sample_rails_project/spec/helpers/people_helper_spec.rb +10 -0
- data/sample_rails_project/spec/rcov.opts +2 -0
- data/sample_rails_project/spec/spec.opts +6 -0
- data/sample_rails_project/spec/spec_helper.rb +43 -0
- data/sample_rails_project/stories/all.rb +4 -0
- data/sample_rails_project/stories/helper.rb +3 -0
- data/sample_rails_project/test/test_helper.rb +30 -0
- data/sample_rails_project/test/unit/database_connection_test.rb +13 -0
- data/sample_rails_project/test/unit/person_test.rb +13 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/.gitignore +7 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/History.txt +40 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/Manifest.txt +151 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/README.txt +81 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/Rakefile +37 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/UPGRADE +7 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/generators/rspec/CHANGES +1 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/generators/rspec/rspec_generator.rb +40 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/generators/rspec/templates/all_stories.rb +4 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/generators/rspec/templates/previous_failures.txt +0 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/generators/rspec/templates/rcov.opts +2 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/generators/rspec/templates/rspec.rake +132 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/generators/rspec/templates/script/autospec +3 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/generators/rspec/templates/script/spec +4 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/generators/rspec/templates/script/spec_server +116 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/generators/rspec/templates/spec.opts +4 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/generators/rspec/templates/spec_helper.rb +47 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/generators/rspec/templates/stories_helper.rb +3 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/generators/rspec_controller/USAGE +33 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/generators/rspec_controller/rspec_controller_generator.rb +49 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/generators/rspec_controller/templates/controller_spec.rb +25 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/generators/rspec_controller/templates/helper_spec.rb +11 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/generators/rspec_controller/templates/view_spec.rb +12 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/generators/rspec_default_values.rb +19 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/generators/rspec_model/USAGE +18 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/generators/rspec_model/rspec_model_generator.rb +35 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/generators/rspec_model/templates/model_spec.rb +15 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/rspec_scaffold_generator.rb +154 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/controller_spec.rb +173 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/edit_erb_spec.rb +26 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/helper_spec.rb +11 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/index_erb_spec.rb +27 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/new_erb_spec.rb +26 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/routing_spec.rb +59 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/generators/rspec_scaffold/templates/show_erb_spec.rb +23 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/init.rb +9 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/lib/autotest/discover.rb +1 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/lib/autotest/rails_rspec.rb +76 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/lib/spec/rails/example/assigns_hash_proxy.rb +43 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/lib/spec/rails/example/controller_example_group.rb +279 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/lib/spec/rails/example/cookies_proxy.rb +25 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/lib/spec/rails/example/functional_example_group.rb +84 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/lib/spec/rails/example/helper_example_group.rb +164 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/lib/spec/rails/example/model_example_group.rb +14 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/lib/spec/rails/example/rails_example_group.rb +33 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/lib/spec/rails/example/render_observer.rb +90 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/lib/spec/rails/example/view_example_group.rb +178 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/lib/spec/rails/example.rb +47 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/action_controller/base.rb +14 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/action_controller/rescue.rb +21 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/action_controller/test_response.rb +11 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/action_view/base.rb +31 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/active_record/base.rb +30 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/object.rb +5 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/spec/example/configuration.rb +71 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/spec/matchers/have.rb +21 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/lib/spec/rails/extensions.rb +12 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/lib/spec/rails/interop/testcase.rb +14 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/assert_select.rb +131 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/have_text.rb +57 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/include_text.rb +54 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/redirect_to.rb +113 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/render_template.rb +90 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers.rb +30 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/lib/spec/rails/mocks.rb +132 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/lib/spec/rails/story_adapter.rb +79 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/lib/spec/rails/version.rb +15 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/lib/spec/rails.rb +15 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec/rails/autotest/mappings_spec.rb +36 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec/rails/example/assigns_hash_proxy_spec.rb +60 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec/rails/example/configuration_spec.rb +83 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec/rails/example/controller_isolation_spec.rb +62 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec/rails/example/controller_spec_spec.rb +260 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec/rails/example/cookies_proxy_spec.rb +74 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec/rails/example/example_group_factory_spec.rb +112 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec/rails/example/helper_spec_spec.rb +161 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec/rails/example/model_spec_spec.rb +18 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec/rails/example/shared_behaviour_spec.rb +16 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec/rails/example/test_unit_assertion_accessibility_spec.rb +33 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec/rails/example/view_spec_spec.rb +268 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec/rails/extensions/action_controller_rescue_action_spec.rb +54 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec/rails/extensions/action_view_base_spec.rb +48 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec/rails/extensions/active_record_spec.rb +14 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec/rails/interop/testcase_spec.rb +66 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec/rails/matchers/assert_select_spec.rb +806 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec/rails/matchers/description_generation_spec.rb +37 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec/rails/matchers/errors_on_spec.rb +13 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec/rails/matchers/have_text_spec.rb +62 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec/rails/matchers/include_text_spec.rb +64 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec/rails/matchers/redirect_to_spec.rb +209 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec/rails/matchers/render_template_spec.rb +176 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec/rails/mocks/ar_classes.rb +10 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec/rails/mocks/mock_model_spec.rb +90 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec/rails/mocks/stub_model_spec.rb +79 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec/rails/sample_modified_fixture.rb +8 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec/rails/sample_spec.rb +8 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec/rails/spec_server_spec.rb +96 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec/rails/spec_spec.rb +11 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec/rails_suite.rb +7 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec/spec_helper.rb +57 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec_resources/controllers/action_view_base_spec_controller.rb +2 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec_resources/controllers/controller_spec_controller.rb +95 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec_resources/controllers/redirect_spec_controller.rb +59 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec_resources/controllers/render_spec_controller.rb +30 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec_resources/controllers/rjs_spec_controller.rb +58 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec_resources/helpers/explicit_helper.rb +38 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec_resources/helpers/more_explicit_helper.rb +5 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec_resources/helpers/plugin_application_helper.rb +6 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec_resources/helpers/view_spec_helper.rb +13 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec_resources/views/controller_spec/_partial.rhtml +0 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec_resources/views/controller_spec/action_setting_flash_after_session_reset.rhtml +1 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec_resources/views/controller_spec/action_setting_flash_before_session_reset.rhtml +1 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec_resources/views/controller_spec/action_setting_the_assigns_hash.rhtml +0 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec_resources/views/controller_spec/action_with_errors_in_template.rhtml +1 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec_resources/views/controller_spec/action_with_template.rhtml +1 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec_resources/views/layouts/application.rhtml +0 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec_resources/views/layouts/simple.rhtml +0 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec_resources/views/objects/_object.html.erb +1 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec_resources/views/render_spec/_a_partial.rhtml +0 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec_resources/views/render_spec/action_with_alternate_layout.rhtml +0 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec_resources/views/render_spec/some_action.js.rjs +1 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec_resources/views/render_spec/some_action.rhtml +0 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec_resources/views/render_spec/some_action.rjs +1 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec_resources/views/rjs_spec/_replacement_partial.rhtml +1 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec_resources/views/rjs_spec/hide_div.rjs +1 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec_resources/views/rjs_spec/hide_page_element.rjs +1 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec_resources/views/rjs_spec/insert_html.rjs +1 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec_resources/views/rjs_spec/replace.rjs +1 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec_resources/views/rjs_spec/replace_html.rjs +1 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec_resources/views/rjs_spec/replace_html_with_partial.rjs +1 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec_resources/views/rjs_spec/visual_effect.rjs +1 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec_resources/views/rjs_spec/visual_toggle_effect.rjs +1 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec_resources/views/tag_spec/no_tags.rhtml +1 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec_resources/views/tag_spec/single_div_with_no_attributes.rhtml +1 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec_resources/views/tag_spec/single_div_with_one_attribute.rhtml +1 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/_partial.rhtml +2 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/_partial_used_twice.rhtml +0 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/_partial_with_local_variable.rhtml +1 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/_partial_with_sub_partial.rhtml +1 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/_spacer.rhtml +1 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/accessor.rhtml +5 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/block_helper.rhtml +3 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/entry_form.rhtml +2 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/explicit_helper.rhtml +2 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/foo/show.rhtml +1 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/implicit_helper.rhtml +2 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/multiple_helpers.rhtml +3 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/template_with_partial.rhtml +5 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/template_with_partial_using_collection.rhtml +3 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/template_with_partial_with_array.rhtml +1 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/stories/all.rb +10 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/stories/configuration/stories.rb +5 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/stories/helper.rb +6 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/stories/steps/people.rb +8 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/stories/transactions_should_rollback +15 -0
- data/sample_rails_project/vendor/plugins/rspec_on_rails/stories/transactions_should_rollback.rb +25 -0
- data/sample_rails_project/vendor/rails/actionmailer/CHANGELOG +297 -0
- data/sample_rails_project/vendor/rails/actionmailer/MIT-LICENSE +21 -0
- data/sample_rails_project/vendor/rails/actionmailer/README +145 -0
- data/sample_rails_project/vendor/rails/actionmailer/Rakefile +95 -0
- data/sample_rails_project/vendor/rails/actionmailer/install.rb +30 -0
- data/sample_rails_project/vendor/rails/actionmailer/lib/action_mailer/adv_attr_accessor.rb +30 -0
- data/sample_rails_project/vendor/rails/actionmailer/lib/action_mailer/base.rb +582 -0
- data/sample_rails_project/vendor/rails/actionmailer/lib/action_mailer/helpers.rb +111 -0
- data/sample_rails_project/vendor/rails/actionmailer/lib/action_mailer/mail_helper.rb +19 -0
- data/sample_rails_project/vendor/rails/actionmailer/lib/action_mailer/part.rb +113 -0
- data/sample_rails_project/vendor/rails/actionmailer/lib/action_mailer/part_container.rb +51 -0
- data/sample_rails_project/vendor/rails/actionmailer/lib/action_mailer/quoting.rb +59 -0
- data/sample_rails_project/vendor/rails/actionmailer/lib/action_mailer/utils.rb +8 -0
- data/sample_rails_project/vendor/rails/actionmailer/lib/action_mailer/vendor/text/format.rb +1466 -0
- data/sample_rails_project/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail/address.rb +242 -0
- data/sample_rails_project/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail/attachments.rb +39 -0
- data/sample_rails_project/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail/base64.rb +71 -0
- data/sample_rails_project/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail/config.rb +69 -0
- data/sample_rails_project/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail/encode.rb +467 -0
- data/sample_rails_project/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail/facade.rb +552 -0
- data/sample_rails_project/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail/header.rb +914 -0
- data/sample_rails_project/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail/info.rb +35 -0
- data/sample_rails_project/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail/loader.rb +1 -0
- data/sample_rails_project/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail/mail.rb +447 -0
- data/sample_rails_project/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail/mailbox.rb +433 -0
- data/sample_rails_project/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail/mbox.rb +1 -0
- data/sample_rails_project/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail/net.rb +280 -0
- data/sample_rails_project/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail/obsolete.rb +135 -0
- data/sample_rails_project/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail/parser.rb +1522 -0
- data/sample_rails_project/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail/port.rb +377 -0
- data/sample_rails_project/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail/quoting.rb +131 -0
- data/sample_rails_project/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail/scanner.rb +41 -0
- data/sample_rails_project/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail/scanner_r.rb +263 -0
- data/sample_rails_project/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail/stringio.rb +277 -0
- data/sample_rails_project/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail/tmail.rb +1 -0
- data/sample_rails_project/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail/utils.rb +238 -0
- data/sample_rails_project/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail.rb +3 -0
- data/sample_rails_project/vendor/rails/actionmailer/lib/action_mailer/version.rb +9 -0
- data/sample_rails_project/vendor/rails/actionmailer/lib/action_mailer.rb +50 -0
- data/sample_rails_project/vendor/rails/actionmailer/test/abstract_unit.rb +30 -0
- data/sample_rails_project/vendor/rails/actionmailer/test/fixtures/first_mailer/share.rhtml +1 -0
- data/sample_rails_project/vendor/rails/actionmailer/test/fixtures/helper_mailer/use_helper.rhtml +1 -0
- data/sample_rails_project/vendor/rails/actionmailer/test/fixtures/helper_mailer/use_helper_method.rhtml +1 -0
- data/sample_rails_project/vendor/rails/actionmailer/test/fixtures/helper_mailer/use_mail_helper.rhtml +5 -0
- data/sample_rails_project/vendor/rails/actionmailer/test/fixtures/helper_mailer/use_test_helper.rhtml +1 -0
- data/sample_rails_project/vendor/rails/actionmailer/test/fixtures/helpers/test_helper.rb +5 -0
- data/sample_rails_project/vendor/rails/actionmailer/test/fixtures/path.with.dots/funky_path_mailer/multipart_with_template_path_with_dots.rhtml +1 -0
- data/sample_rails_project/vendor/rails/actionmailer/test/fixtures/path.with.dots/multipart_with_template_path_with_dots.rhtml +0 -0
- data/sample_rails_project/vendor/rails/actionmailer/test/fixtures/raw_email +14 -0
- data/sample_rails_project/vendor/rails/actionmailer/test/fixtures/raw_email10 +20 -0
- data/sample_rails_project/vendor/rails/actionmailer/test/fixtures/raw_email11 +34 -0
- data/sample_rails_project/vendor/rails/actionmailer/test/fixtures/raw_email12 +32 -0
- data/sample_rails_project/vendor/rails/actionmailer/test/fixtures/raw_email13 +29 -0
- data/sample_rails_project/vendor/rails/actionmailer/test/fixtures/raw_email2 +114 -0
- data/sample_rails_project/vendor/rails/actionmailer/test/fixtures/raw_email3 +70 -0
- data/sample_rails_project/vendor/rails/actionmailer/test/fixtures/raw_email4 +59 -0
- data/sample_rails_project/vendor/rails/actionmailer/test/fixtures/raw_email5 +19 -0
- data/sample_rails_project/vendor/rails/actionmailer/test/fixtures/raw_email6 +20 -0
- data/sample_rails_project/vendor/rails/actionmailer/test/fixtures/raw_email7 +66 -0
- data/sample_rails_project/vendor/rails/actionmailer/test/fixtures/raw_email8 +47 -0
- data/sample_rails_project/vendor/rails/actionmailer/test/fixtures/raw_email9 +28 -0
- data/sample_rails_project/vendor/rails/actionmailer/test/fixtures/raw_email_quoted_with_0d0a +14 -0
- data/sample_rails_project/vendor/rails/actionmailer/test/fixtures/raw_email_with_partially_quoted_subject +14 -0
- data/sample_rails_project/vendor/rails/actionmailer/test/fixtures/second_mailer/share.rhtml +1 -0
- data/sample_rails_project/vendor/rails/actionmailer/test/fixtures/templates/signed_up.rhtml +3 -0
- data/sample_rails_project/vendor/rails/actionmailer/test/fixtures/test_mailer/implicitly_multipart_example.ignored.rhtml +1 -0
- data/sample_rails_project/vendor/rails/actionmailer/test/fixtures/test_mailer/implicitly_multipart_example.text.html.rhtml +10 -0
- data/sample_rails_project/vendor/rails/actionmailer/test/fixtures/test_mailer/implicitly_multipart_example.text.plain.rhtml +2 -0
- data/sample_rails_project/vendor/rails/actionmailer/test/fixtures/test_mailer/implicitly_multipart_example.text.yaml.rhtml +1 -0
- data/sample_rails_project/vendor/rails/actionmailer/test/fixtures/test_mailer/signed_up.rhtml +3 -0
- data/sample_rails_project/vendor/rails/actionmailer/test/fixtures/test_mailer/signed_up_with_url.rhtml +3 -0
- data/sample_rails_project/vendor/rails/actionmailer/test/mail_helper_test.rb +91 -0
- data/sample_rails_project/vendor/rails/actionmailer/test/mail_render_test.rb +79 -0
- data/sample_rails_project/vendor/rails/actionmailer/test/mail_service_test.rb +816 -0
- data/sample_rails_project/vendor/rails/actionmailer/test/quoting_test.rb +57 -0
- data/sample_rails_project/vendor/rails/actionmailer/test/tmail_test.rb +13 -0
- data/sample_rails_project/vendor/rails/actionmailer/test/url_test.rb +68 -0
- data/sample_rails_project/vendor/rails/actionpack/CHANGELOG +3138 -0
- data/sample_rails_project/vendor/rails/actionpack/MIT-LICENSE +21 -0
- data/sample_rails_project/vendor/rails/actionpack/README +469 -0
- data/sample_rails_project/vendor/rails/actionpack/RUNNING_UNIT_TESTS +25 -0
- data/sample_rails_project/vendor/rails/actionpack/Rakefile +154 -0
- data/sample_rails_project/vendor/rails/actionpack/examples/.htaccess +24 -0
- data/sample_rails_project/vendor/rails/actionpack/examples/address_book/index.rhtml +33 -0
- data/sample_rails_project/vendor/rails/actionpack/examples/address_book/layout.rhtml +8 -0
- data/sample_rails_project/vendor/rails/actionpack/examples/address_book_controller.cgi +9 -0
- data/sample_rails_project/vendor/rails/actionpack/examples/address_book_controller.fcgi +6 -0
- data/sample_rails_project/vendor/rails/actionpack/examples/address_book_controller.rb +52 -0
- data/sample_rails_project/vendor/rails/actionpack/examples/address_book_controller.rbx +4 -0
- data/sample_rails_project/vendor/rails/actionpack/examples/benchmark.rb +52 -0
- data/sample_rails_project/vendor/rails/actionpack/examples/benchmark_with_ar.fcgi +89 -0
- data/sample_rails_project/vendor/rails/actionpack/examples/blog_controller.cgi +53 -0
- data/sample_rails_project/vendor/rails/actionpack/examples/debate/index.rhtml +14 -0
- data/sample_rails_project/vendor/rails/actionpack/examples/debate/new_topic.rhtml +22 -0
- data/sample_rails_project/vendor/rails/actionpack/examples/debate/topic.rhtml +32 -0
- data/sample_rails_project/vendor/rails/actionpack/examples/debate_controller.cgi +57 -0
- data/sample_rails_project/vendor/rails/actionpack/install.rb +30 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/assertions/deprecated_assertions.rb +228 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/assertions/dom_assertions.rb +25 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/assertions/model_assertions.rb +12 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/assertions/response_assertions.rb +140 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/assertions/routing_assertions.rb +98 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/assertions/selector_assertions.rb +571 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/assertions/tag_assertions.rb +117 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/assertions.rb +82 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/base.rb +1231 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/benchmarking.rb +89 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/caching.rb +616 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/cgi_ext/cgi_ext.rb +36 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/cgi_ext/cgi_methods.rb +211 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/cgi_ext/cookie_performance_fix.rb +125 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/cgi_ext/raw_post_data_fix.rb +95 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/cgi_ext/session_performance_fix.rb +30 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/cgi_process.rb +231 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/components.rb +182 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/cookies.rb +78 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/deprecated_dependencies.rb +65 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/deprecated_redirects.rb +17 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/deprecated_request_methods.rb +34 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/filters.rb +667 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/flash.rb +182 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/helpers.rb +131 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/integration.rb +552 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/layout.rb +313 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/macros/auto_complete.rb +53 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/macros/in_place_editing.rb +33 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/mime_responds.rb +181 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/mime_type.rb +200 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/pagination.rb +402 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/request.rb +265 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/rescue.rb +142 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/resources.rb +405 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/response.rb +35 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/routing.rb +1340 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/scaffolding.rb +189 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/session/active_record_store.rb +335 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/session/drb_server.rb +32 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/session/drb_store.rb +35 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/session/mem_cache_store.rb +105 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/session_management.rb +142 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/status_codes.rb +88 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/streaming.rb +138 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/templates/rescues/_request_and_response.rhtml +44 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/templates/rescues/_trace.rhtml +26 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/templates/rescues/diagnostics.rhtml +11 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/templates/rescues/layout.rhtml +29 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/templates/rescues/missing_template.rhtml +2 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/templates/rescues/routing_error.rhtml +10 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/templates/rescues/template_error.rhtml +21 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/templates/rescues/unknown_action.rhtml +2 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/templates/scaffolds/edit.rhtml +7 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/templates/scaffolds/layout.rhtml +69 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/templates/scaffolds/list.rhtml +27 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/templates/scaffolds/new.rhtml +6 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/templates/scaffolds/show.rhtml +9 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/test_process.rb +504 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/url_rewriter.rb +108 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/vendor/html-scanner/html/document.rb +65 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/vendor/html-scanner/html/node.rb +530 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/vendor/html-scanner/html/selector.rb +823 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/vendor/html-scanner/html/tokenizer.rb +105 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/vendor/html-scanner/html/version.rb +11 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/vendor/xml_node.rb +97 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller/verification.rb +107 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_controller.rb +83 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_pack/version.rb +9 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_pack.rb +24 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_view/base.rb +538 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_view/compiled_templates.rb +70 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_view/helpers/active_record_helper.rb +237 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_view/helpers/asset_tag_helper.rb +218 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_view/helpers/benchmark_helper.rb +24 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_view/helpers/cache_helper.rb +10 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_view/helpers/capture_helper.rb +128 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_view/helpers/date_helper.rb +429 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_view/helpers/debug_helper.rb +17 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_view/helpers/deprecated_helper.rb +34 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_view/helpers/form_helper.rb +446 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_view/helpers/form_options_helper.rb +363 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_view/helpers/form_tag_helper.rb +176 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_view/helpers/java_script_macros_helper.rb +233 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_view/helpers/javascript_helper.rb +193 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_view/helpers/javascripts/controls.js +833 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_view/helpers/javascripts/dragdrop.js +942 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_view/helpers/javascripts/effects.js +1088 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_view/helpers/javascripts/prototype.js +2515 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_view/helpers/number_helper.rb +155 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_view/helpers/pagination_helper.rb +86 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_view/helpers/prototype_helper.rb +876 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_view/helpers/scriptaculous_helper.rb +140 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_view/helpers/tag_helper.rb +103 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_view/helpers/text_helper.rb +406 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_view/helpers/url_helper.rb +406 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_view/partials.rb +128 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_view/template_error.rb +110 -0
- data/sample_rails_project/vendor/rails/actionpack/lib/action_view.rb +32 -0
- data/sample_rails_project/vendor/rails/actionpack/test/abstract_unit.rb +16 -0
- data/sample_rails_project/vendor/rails/actionpack/test/active_record_unit.rb +116 -0
- data/sample_rails_project/vendor/rails/actionpack/test/activerecord/active_record_assertions_test.rb +92 -0
- data/sample_rails_project/vendor/rails/actionpack/test/activerecord/active_record_store_test.rb +142 -0
- data/sample_rails_project/vendor/rails/actionpack/test/activerecord/pagination_test.rb +156 -0
- data/sample_rails_project/vendor/rails/actionpack/test/controller/action_pack_assertions_test.rb +610 -0
- data/sample_rails_project/vendor/rails/actionpack/test/controller/addresses_render_test.rb +45 -0
- data/sample_rails_project/vendor/rails/actionpack/test/controller/assert_select_test.rb +576 -0
- data/sample_rails_project/vendor/rails/actionpack/test/controller/base_test.rb +136 -0
- data/sample_rails_project/vendor/rails/actionpack/test/controller/benchmark_test.rb +33 -0
- data/sample_rails_project/vendor/rails/actionpack/test/controller/caching_test.rb +228 -0
- data/sample_rails_project/vendor/rails/actionpack/test/controller/capture_test.rb +82 -0
- data/sample_rails_project/vendor/rails/actionpack/test/controller/cgi_test.rb +440 -0
- data/sample_rails_project/vendor/rails/actionpack/test/controller/components_test.rb +151 -0
- data/sample_rails_project/vendor/rails/actionpack/test/controller/content_type_test.rb +139 -0
- data/sample_rails_project/vendor/rails/actionpack/test/controller/controller_fixtures/app/controllers/admin/user_controller.rb +0 -0
- data/sample_rails_project/vendor/rails/actionpack/test/controller/controller_fixtures/app/controllers/user_controller.rb +0 -0
- data/sample_rails_project/vendor/rails/actionpack/test/controller/controller_fixtures/vendor/plugins/bad_plugin/lib/plugin_controller.rb +0 -0
- data/sample_rails_project/vendor/rails/actionpack/test/controller/cookie_test.rb +88 -0
- data/sample_rails_project/vendor/rails/actionpack/test/controller/custom_handler_test.rb +41 -0
- data/sample_rails_project/vendor/rails/actionpack/test/controller/deprecated_instance_variables_test.rb +48 -0
- data/sample_rails_project/vendor/rails/actionpack/test/controller/deprecation/deprecated_base_methods_test.rb +60 -0
- data/sample_rails_project/vendor/rails/actionpack/test/controller/fake_controllers.rb +16 -0
- data/sample_rails_project/vendor/rails/actionpack/test/controller/filter_params_test.rb +42 -0
- data/sample_rails_project/vendor/rails/actionpack/test/controller/filters_test.rb +695 -0
- data/sample_rails_project/vendor/rails/actionpack/test/controller/flash_test.rb +102 -0
- data/sample_rails_project/vendor/rails/actionpack/test/controller/fragment_store_setting_test.rb +45 -0
- data/sample_rails_project/vendor/rails/actionpack/test/controller/helper_test.rb +187 -0
- data/sample_rails_project/vendor/rails/actionpack/test/controller/integration_test.rb +154 -0
- data/sample_rails_project/vendor/rails/actionpack/test/controller/layout_test.rb +187 -0
- data/sample_rails_project/vendor/rails/actionpack/test/controller/mime_responds_test.rb +351 -0
- data/sample_rails_project/vendor/rails/actionpack/test/controller/mime_type_test.rb +33 -0
- data/sample_rails_project/vendor/rails/actionpack/test/controller/new_render_test.rb +750 -0
- data/sample_rails_project/vendor/rails/actionpack/test/controller/raw_post_test.rb +68 -0
- data/sample_rails_project/vendor/rails/actionpack/test/controller/redirect_test.rb +156 -0
- data/sample_rails_project/vendor/rails/actionpack/test/controller/render_test.rb +293 -0
- data/sample_rails_project/vendor/rails/actionpack/test/controller/request_test.rb +317 -0
- data/sample_rails_project/vendor/rails/actionpack/test/controller/resources_test.rb +482 -0
- data/sample_rails_project/vendor/rails/actionpack/test/controller/routing_test.rb +1801 -0
- data/sample_rails_project/vendor/rails/actionpack/test/controller/selector_test.rb +628 -0
- data/sample_rails_project/vendor/rails/actionpack/test/controller/send_file_test.rb +117 -0
- data/sample_rails_project/vendor/rails/actionpack/test/controller/session_management_test.rb +156 -0
- data/sample_rails_project/vendor/rails/actionpack/test/controller/test_test.rb +495 -0
- data/sample_rails_project/vendor/rails/actionpack/test/controller/url_rewriter_test.rb +115 -0
- data/sample_rails_project/vendor/rails/actionpack/test/controller/verification_test.rb +227 -0
- data/sample_rails_project/vendor/rails/actionpack/test/controller/webservice_test.rb +248 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/addresses/list.rhtml +1 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/companies.yml +24 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/company.rb +9 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/content_type/render_default_content_types_for_respond_to.rhtml +1 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/content_type/render_default_for_rhtml.rhtml +1 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/content_type/render_default_for_rjs.rjs +1 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/content_type/render_default_for_rxml.rxml +1 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/db_definitions/sqlite.sql +42 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/deprecated_instance_variables/_cookies_ivar.rhtml +1 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/deprecated_instance_variables/_cookies_method.rhtml +1 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/deprecated_instance_variables/_flash_ivar.rhtml +1 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/deprecated_instance_variables/_flash_method.rhtml +1 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/deprecated_instance_variables/_headers_ivar.rhtml +1 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/deprecated_instance_variables/_headers_method.rhtml +1 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/deprecated_instance_variables/_params_ivar.rhtml +1 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/deprecated_instance_variables/_params_method.rhtml +1 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/deprecated_instance_variables/_request_ivar.rhtml +1 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/deprecated_instance_variables/_request_method.rhtml +1 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/deprecated_instance_variables/_response_ivar.rhtml +1 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/deprecated_instance_variables/_response_method.rhtml +1 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/deprecated_instance_variables/_session_ivar.rhtml +1 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/deprecated_instance_variables/_session_method.rhtml +1 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/developer.rb +7 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/developers.yml +21 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/developers_projects.yml +13 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/fun/games/hello_world.rhtml +1 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/helpers/abc_helper.rb +5 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/helpers/fun/games_helper.rb +3 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/helpers/fun/pdf_helper.rb +3 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/layout_tests/layouts/controller_name_space/nested.rhtml +1 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/layout_tests/layouts/item.rhtml +1 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/layout_tests/layouts/layout_test.rhtml +1 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/layout_tests/layouts/third_party_template_library.mab +1 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/layout_tests/views/hello.rhtml +1 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/layouts/builder.rxml +3 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/layouts/standard.rhtml +1 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/layouts/talk_from_action.rhtml +2 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/layouts/yield.rhtml +2 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/multipart/binary_file +0 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/multipart/large_text_file +10 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/multipart/mixed_files +0 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/multipart/mona_lisa.jpg +0 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/multipart/single_parameter +5 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/multipart/text_file +10 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/project.rb +3 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/projects.yml +7 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/public/images/rails.png +0 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/public/javascripts/application.js +1 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/replies.yml +13 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/reply.rb +5 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/respond_to/all_types_with_layout.rhtml +1 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/respond_to/all_types_with_layout.rjs +1 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/respond_to/layouts/standard.rhtml +1 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults.rhtml +1 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults.rjs +1 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults.rxml +1 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults_with_type_list.rhtml +1 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults_with_type_list.rjs +1 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults_with_type_list.rxml +1 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/scope/test/modgreet.rhtml +1 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/test/_customer.rhtml +1 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/test/_customer_greeting.rhtml +1 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/test/_hash_object.rhtml +1 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/test/_hello.rxml +1 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/test/_partial_only.rhtml +1 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/test/_person.rhtml +2 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/test/action_talk_to_layout.rhtml +2 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/test/block_content_for.rhtml +2 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/test/capturing.rhtml +4 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/test/content_for.rhtml +2 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/test/delete_with_js.rjs +2 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/test/dot.directory/render_file_with_ivar.rhtml +1 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/test/enum_rjs_test.rjs +6 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/test/erb_content_for.rhtml +2 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/test/greeting.rhtml +1 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/test/hello.rxml +4 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/test/hello_world.rhtml +1 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/test/hello_world.rxml +3 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/test/hello_world_container.rxml +3 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/test/hello_world_with_layout_false.rhtml +1 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/test/hello_xml_world.rxml +11 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/test/list.rhtml +1 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/test/non_erb_block_content_for.rxml +4 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/test/potential_conflicts.rhtml +4 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/test/render_file_with_ivar.rhtml +1 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/test/render_file_with_locals.rhtml +1 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/test/render_to_string_test.rhtml +1 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/test/update_element_with_capture.rhtml +9 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/topic.rb +3 -0
- data/sample_rails_project/vendor/rails/actionpack/test/fixtures/topics.yml +22 -0
- data/sample_rails_project/vendor/rails/actionpack/test/template/active_record_helper_test.rb +204 -0
- data/sample_rails_project/vendor/rails/actionpack/test/template/asset_tag_helper_test.rb +232 -0
- data/sample_rails_project/vendor/rails/actionpack/test/template/benchmark_helper_test.rb +72 -0
- data/sample_rails_project/vendor/rails/actionpack/test/template/compiled_templates_test.rb +135 -0
- data/sample_rails_project/vendor/rails/actionpack/test/template/date_helper_test.rb +1322 -0
- data/sample_rails_project/vendor/rails/actionpack/test/template/deprecated_helper_test.rb +36 -0
- data/sample_rails_project/vendor/rails/actionpack/test/template/deprecated_instance_variables_test.rb +43 -0
- data/sample_rails_project/vendor/rails/actionpack/test/template/form_helper_test.rb +499 -0
- data/sample_rails_project/vendor/rails/actionpack/test/template/form_options_helper_test.rb +489 -0
- data/sample_rails_project/vendor/rails/actionpack/test/template/form_tag_helper_test.rb +172 -0
- data/sample_rails_project/vendor/rails/actionpack/test/template/java_script_macros_helper_test.rb +109 -0
- data/sample_rails_project/vendor/rails/actionpack/test/template/javascript_helper_test.rb +67 -0
- data/sample_rails_project/vendor/rails/actionpack/test/template/number_helper_test.rb +92 -0
- data/sample_rails_project/vendor/rails/actionpack/test/template/prototype_helper_test.rb +466 -0
- data/sample_rails_project/vendor/rails/actionpack/test/template/scriptaculous_helper_test.rb +90 -0
- data/sample_rails_project/vendor/rails/actionpack/test/template/tag_helper_test.rb +69 -0
- data/sample_rails_project/vendor/rails/actionpack/test/template/text_helper_test.rb +349 -0
- data/sample_rails_project/vendor/rails/actionpack/test/template/url_helper_test.rb +366 -0
- data/sample_rails_project/vendor/rails/actionpack/test/testing_sandbox.rb +11 -0
- data/sample_rails_project/vendor/rails/actionwebservice/CHANGELOG +279 -0
- data/sample_rails_project/vendor/rails/actionwebservice/MIT-LICENSE +21 -0
- data/sample_rails_project/vendor/rails/actionwebservice/README +364 -0
- data/sample_rails_project/vendor/rails/actionwebservice/Rakefile +171 -0
- data/sample_rails_project/vendor/rails/actionwebservice/TODO +32 -0
- data/sample_rails_project/vendor/rails/actionwebservice/examples/googlesearch/README +143 -0
- data/sample_rails_project/vendor/rails/actionwebservice/examples/googlesearch/autoloading/google_search_api.rb +50 -0
- data/sample_rails_project/vendor/rails/actionwebservice/examples/googlesearch/autoloading/google_search_controller.rb +57 -0
- data/sample_rails_project/vendor/rails/actionwebservice/examples/googlesearch/delegated/google_search_service.rb +108 -0
- data/sample_rails_project/vendor/rails/actionwebservice/examples/googlesearch/delegated/search_controller.rb +7 -0
- data/sample_rails_project/vendor/rails/actionwebservice/examples/googlesearch/direct/google_search_api.rb +50 -0
- data/sample_rails_project/vendor/rails/actionwebservice/examples/googlesearch/direct/search_controller.rb +58 -0
- data/sample_rails_project/vendor/rails/actionwebservice/examples/metaWeblog/README +17 -0
- data/sample_rails_project/vendor/rails/actionwebservice/examples/metaWeblog/apis/blogger_api.rb +60 -0
- data/sample_rails_project/vendor/rails/actionwebservice/examples/metaWeblog/apis/blogger_service.rb +34 -0
- data/sample_rails_project/vendor/rails/actionwebservice/examples/metaWeblog/apis/meta_weblog_api.rb +67 -0
- data/sample_rails_project/vendor/rails/actionwebservice/examples/metaWeblog/apis/meta_weblog_service.rb +48 -0
- data/sample_rails_project/vendor/rails/actionwebservice/examples/metaWeblog/controllers/xmlrpc_controller.rb +16 -0
- data/sample_rails_project/vendor/rails/actionwebservice/lib/action_web_service/api.rb +249 -0
- data/sample_rails_project/vendor/rails/actionwebservice/lib/action_web_service/base.rb +42 -0
- data/sample_rails_project/vendor/rails/actionwebservice/lib/action_web_service/casting.rb +136 -0
- data/sample_rails_project/vendor/rails/actionwebservice/lib/action_web_service/client/base.rb +28 -0
- data/sample_rails_project/vendor/rails/actionwebservice/lib/action_web_service/client/soap_client.rb +113 -0
- data/sample_rails_project/vendor/rails/actionwebservice/lib/action_web_service/client/xmlrpc_client.rb +58 -0
- data/sample_rails_project/vendor/rails/actionwebservice/lib/action_web_service/client.rb +3 -0
- data/sample_rails_project/vendor/rails/actionwebservice/lib/action_web_service/container/action_controller_container.rb +93 -0
- data/sample_rails_project/vendor/rails/actionwebservice/lib/action_web_service/container/delegated_container.rb +86 -0
- data/sample_rails_project/vendor/rails/actionwebservice/lib/action_web_service/container/direct_container.rb +69 -0
- data/sample_rails_project/vendor/rails/actionwebservice/lib/action_web_service/container.rb +3 -0
- data/sample_rails_project/vendor/rails/actionwebservice/lib/action_web_service/dispatcher/abstract.rb +203 -0
- data/sample_rails_project/vendor/rails/actionwebservice/lib/action_web_service/dispatcher/action_controller_dispatcher.rb +376 -0
- data/sample_rails_project/vendor/rails/actionwebservice/lib/action_web_service/dispatcher.rb +2 -0
- data/sample_rails_project/vendor/rails/actionwebservice/lib/action_web_service/invocation.rb +202 -0
- data/sample_rails_project/vendor/rails/actionwebservice/lib/action_web_service/protocol/abstract.rb +112 -0
- data/sample_rails_project/vendor/rails/actionwebservice/lib/action_web_service/protocol/discovery.rb +37 -0
- data/sample_rails_project/vendor/rails/actionwebservice/lib/action_web_service/protocol/soap_protocol/marshaler.rb +241 -0
- data/sample_rails_project/vendor/rails/actionwebservice/lib/action_web_service/protocol/soap_protocol.rb +176 -0
- data/sample_rails_project/vendor/rails/actionwebservice/lib/action_web_service/protocol/xmlrpc_protocol.rb +110 -0
- data/sample_rails_project/vendor/rails/actionwebservice/lib/action_web_service/protocol.rb +4 -0
- data/sample_rails_project/vendor/rails/actionwebservice/lib/action_web_service/scaffolding.rb +283 -0
- data/sample_rails_project/vendor/rails/actionwebservice/lib/action_web_service/struct.rb +68 -0
- data/sample_rails_project/vendor/rails/actionwebservice/lib/action_web_service/support/class_inheritable_options.rb +26 -0
- data/sample_rails_project/vendor/rails/actionwebservice/lib/action_web_service/support/signature_types.rb +222 -0
- data/sample_rails_project/vendor/rails/actionwebservice/lib/action_web_service/templates/scaffolds/layout.rhtml +65 -0
- data/sample_rails_project/vendor/rails/actionwebservice/lib/action_web_service/templates/scaffolds/methods.rhtml +6 -0
- data/sample_rails_project/vendor/rails/actionwebservice/lib/action_web_service/templates/scaffolds/parameters.rhtml +29 -0
- data/sample_rails_project/vendor/rails/actionwebservice/lib/action_web_service/templates/scaffolds/result.rhtml +30 -0
- data/sample_rails_project/vendor/rails/actionwebservice/lib/action_web_service/test_invoke.rb +110 -0
- data/sample_rails_project/vendor/rails/actionwebservice/lib/action_web_service/version.rb +9 -0
- data/sample_rails_project/vendor/rails/actionwebservice/lib/action_web_service.rb +66 -0
- data/sample_rails_project/vendor/rails/actionwebservice/setup.rb +1379 -0
- data/sample_rails_project/vendor/rails/actionwebservice/test/abstract_client.rb +183 -0
- data/sample_rails_project/vendor/rails/actionwebservice/test/abstract_dispatcher.rb +505 -0
- data/sample_rails_project/vendor/rails/actionwebservice/test/abstract_unit.rb +45 -0
- data/sample_rails_project/vendor/rails/actionwebservice/test/api_test.rb +102 -0
- data/sample_rails_project/vendor/rails/actionwebservice/test/apis/auto_load_api.rb +3 -0
- data/sample_rails_project/vendor/rails/actionwebservice/test/apis/broken_auto_load_api.rb +2 -0
- data/sample_rails_project/vendor/rails/actionwebservice/test/base_test.rb +42 -0
- data/sample_rails_project/vendor/rails/actionwebservice/test/casting_test.rb +86 -0
- data/sample_rails_project/vendor/rails/actionwebservice/test/client_soap_test.rb +152 -0
- data/sample_rails_project/vendor/rails/actionwebservice/test/client_xmlrpc_test.rb +151 -0
- data/sample_rails_project/vendor/rails/actionwebservice/test/container_test.rb +73 -0
- data/sample_rails_project/vendor/rails/actionwebservice/test/dispatcher_action_controller_soap_test.rb +137 -0
- data/sample_rails_project/vendor/rails/actionwebservice/test/dispatcher_action_controller_xmlrpc_test.rb +59 -0
- data/sample_rails_project/vendor/rails/actionwebservice/test/fixtures/db_definitions/mysql.sql +7 -0
- data/sample_rails_project/vendor/rails/actionwebservice/test/fixtures/users.yml +10 -0
- data/sample_rails_project/vendor/rails/actionwebservice/test/gencov +3 -0
- data/sample_rails_project/vendor/rails/actionwebservice/test/invocation_test.rb +185 -0
- data/sample_rails_project/vendor/rails/actionwebservice/test/run +6 -0
- data/sample_rails_project/vendor/rails/actionwebservice/test/scaffolded_controller_test.rb +146 -0
- data/sample_rails_project/vendor/rails/actionwebservice/test/struct_test.rb +52 -0
- data/sample_rails_project/vendor/rails/actionwebservice/test/test_invoke_test.rb +112 -0
- data/sample_rails_project/vendor/rails/activerecord/CHANGELOG +3043 -0
- data/sample_rails_project/vendor/rails/activerecord/README +360 -0
- data/sample_rails_project/vendor/rails/activerecord/RUNNING_UNIT_TESTS +64 -0
- data/sample_rails_project/vendor/rails/activerecord/Rakefile +226 -0
- data/sample_rails_project/vendor/rails/activerecord/examples/associations.png +0 -0
- data/sample_rails_project/vendor/rails/activerecord/examples/associations.rb +87 -0
- data/sample_rails_project/vendor/rails/activerecord/examples/shared_setup.rb +15 -0
- data/sample_rails_project/vendor/rails/activerecord/examples/validation.rb +85 -0
- data/sample_rails_project/vendor/rails/activerecord/install.rb +30 -0
- data/sample_rails_project/vendor/rails/activerecord/lib/active_record/acts/list.rb +244 -0
- data/sample_rails_project/vendor/rails/activerecord/lib/active_record/acts/nested_set.rb +211 -0
- data/sample_rails_project/vendor/rails/activerecord/lib/active_record/acts/tree.rb +89 -0
- data/sample_rails_project/vendor/rails/activerecord/lib/active_record/aggregations.rb +191 -0
- data/sample_rails_project/vendor/rails/activerecord/lib/active_record/associations/association_collection.rb +190 -0
- data/sample_rails_project/vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb +158 -0
- data/sample_rails_project/vendor/rails/activerecord/lib/active_record/associations/belongs_to_association.rb +56 -0
- data/sample_rails_project/vendor/rails/activerecord/lib/active_record/associations/belongs_to_polymorphic_association.rb +50 -0
- data/sample_rails_project/vendor/rails/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb +169 -0
- data/sample_rails_project/vendor/rails/activerecord/lib/active_record/associations/has_many_association.rb +210 -0
- data/sample_rails_project/vendor/rails/activerecord/lib/active_record/associations/has_many_through_association.rb +247 -0
- data/sample_rails_project/vendor/rails/activerecord/lib/active_record/associations/has_one_association.rb +80 -0
- data/sample_rails_project/vendor/rails/activerecord/lib/active_record/associations.rb +1627 -0
- data/sample_rails_project/vendor/rails/activerecord/lib/active_record/attribute_methods.rb +75 -0
- data/sample_rails_project/vendor/rails/activerecord/lib/active_record/base.rb +2164 -0
- data/sample_rails_project/vendor/rails/activerecord/lib/active_record/calculations.rb +270 -0
- data/sample_rails_project/vendor/rails/activerecord/lib/active_record/callbacks.rb +367 -0
- data/sample_rails_project/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb +279 -0
- data/sample_rails_project/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb +130 -0
- data/sample_rails_project/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb +58 -0
- data/sample_rails_project/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb +343 -0
- data/sample_rails_project/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb +303 -0
- data/sample_rails_project/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb +161 -0
- data/sample_rails_project/vendor/rails/activerecord/lib/active_record/connection_adapters/db2_adapter.rb +228 -0
- data/sample_rails_project/vendor/rails/activerecord/lib/active_record/connection_adapters/firebird_adapter.rb +728 -0
- data/sample_rails_project/vendor/rails/activerecord/lib/active_record/connection_adapters/frontbase_adapter.rb +861 -0
- data/sample_rails_project/vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb +414 -0
- data/sample_rails_project/vendor/rails/activerecord/lib/active_record/connection_adapters/openbase_adapter.rb +350 -0
- data/sample_rails_project/vendor/rails/activerecord/lib/active_record/connection_adapters/oracle_adapter.rb +689 -0
- data/sample_rails_project/vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +584 -0
- data/sample_rails_project/vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb +407 -0
- data/sample_rails_project/vendor/rails/activerecord/lib/active_record/connection_adapters/sqlserver_adapter.rb +591 -0
- data/sample_rails_project/vendor/rails/activerecord/lib/active_record/connection_adapters/sybase_adapter.rb +662 -0
- data/sample_rails_project/vendor/rails/activerecord/lib/active_record/deprecated_associations.rb +104 -0
- data/sample_rails_project/vendor/rails/activerecord/lib/active_record/deprecated_finders.rb +44 -0
- data/sample_rails_project/vendor/rails/activerecord/lib/active_record/fixtures.rb +628 -0
- data/sample_rails_project/vendor/rails/activerecord/lib/active_record/locking/optimistic.rb +106 -0
- data/sample_rails_project/vendor/rails/activerecord/lib/active_record/locking/pessimistic.rb +77 -0
- data/sample_rails_project/vendor/rails/activerecord/lib/active_record/migration.rb +394 -0
- data/sample_rails_project/vendor/rails/activerecord/lib/active_record/observer.rb +178 -0
- data/sample_rails_project/vendor/rails/activerecord/lib/active_record/query_cache.rb +64 -0
- data/sample_rails_project/vendor/rails/activerecord/lib/active_record/reflection.rb +222 -0
- data/sample_rails_project/vendor/rails/activerecord/lib/active_record/schema.rb +58 -0
- data/sample_rails_project/vendor/rails/activerecord/lib/active_record/schema_dumper.rb +149 -0
- data/sample_rails_project/vendor/rails/activerecord/lib/active_record/timestamp.rb +51 -0
- data/sample_rails_project/vendor/rails/activerecord/lib/active_record/transactions.rb +136 -0
- data/sample_rails_project/vendor/rails/activerecord/lib/active_record/validations.rb +843 -0
- data/sample_rails_project/vendor/rails/activerecord/lib/active_record/vendor/db2.rb +362 -0
- data/sample_rails_project/vendor/rails/activerecord/lib/active_record/vendor/mysql.rb +1214 -0
- data/sample_rails_project/vendor/rails/activerecord/lib/active_record/vendor/simple.rb +693 -0
- data/sample_rails_project/vendor/rails/activerecord/lib/active_record/version.rb +9 -0
- data/sample_rails_project/vendor/rails/activerecord/lib/active_record/wrappers/yaml_wrapper.rb +15 -0
- data/sample_rails_project/vendor/rails/activerecord/lib/active_record/wrappings.rb +58 -0
- data/sample_rails_project/vendor/rails/activerecord/lib/active_record/xml_serialization.rb +308 -0
- data/sample_rails_project/vendor/rails/activerecord/lib/active_record.rb +85 -0
- data/sample_rails_project/vendor/rails/activerecord/test/aaa_create_tables_test.rb +59 -0
- data/sample_rails_project/vendor/rails/activerecord/test/abstract_unit.rb +77 -0
- data/sample_rails_project/vendor/rails/activerecord/test/active_schema_test_mysql.rb +31 -0
- data/sample_rails_project/vendor/rails/activerecord/test/adapter_test.rb +87 -0
- data/sample_rails_project/vendor/rails/activerecord/test/adapter_test_sqlserver.rb +81 -0
- data/sample_rails_project/vendor/rails/activerecord/test/aggregations_test.rb +95 -0
- data/sample_rails_project/vendor/rails/activerecord/test/all.sh +8 -0
- data/sample_rails_project/vendor/rails/activerecord/test/ar_schema_test.rb +33 -0
- data/sample_rails_project/vendor/rails/activerecord/test/association_inheritance_reload.rb +14 -0
- data/sample_rails_project/vendor/rails/activerecord/test/associations/callbacks_test.rb +126 -0
- data/sample_rails_project/vendor/rails/activerecord/test/associations/cascaded_eager_loading_test.rb +138 -0
- data/sample_rails_project/vendor/rails/activerecord/test/associations/eager_test.rb +393 -0
- data/sample_rails_project/vendor/rails/activerecord/test/associations/extension_test.rb +42 -0
- data/sample_rails_project/vendor/rails/activerecord/test/associations/join_model_test.rb +497 -0
- data/sample_rails_project/vendor/rails/activerecord/test/associations_test.rb +1809 -0
- data/sample_rails_project/vendor/rails/activerecord/test/attribute_methods_test.rb +49 -0
- data/sample_rails_project/vendor/rails/activerecord/test/base_test.rb +1586 -0
- data/sample_rails_project/vendor/rails/activerecord/test/binary_test.rb +37 -0
- data/sample_rails_project/vendor/rails/activerecord/test/calculations_test.rb +219 -0
- data/sample_rails_project/vendor/rails/activerecord/test/callbacks_test.rb +377 -0
- data/sample_rails_project/vendor/rails/activerecord/test/class_inheritable_attributes_test.rb +32 -0
- data/sample_rails_project/vendor/rails/activerecord/test/column_alias_test.rb +17 -0
- data/sample_rails_project/vendor/rails/activerecord/test/connection_test_firebird.rb +8 -0
- data/sample_rails_project/vendor/rails/activerecord/test/connections/native_db2/connection.rb +25 -0
- data/sample_rails_project/vendor/rails/activerecord/test/connections/native_firebird/connection.rb +26 -0
- data/sample_rails_project/vendor/rails/activerecord/test/connections/native_frontbase/connection.rb +27 -0
- data/sample_rails_project/vendor/rails/activerecord/test/connections/native_mysql/connection.rb +24 -0
- data/sample_rails_project/vendor/rails/activerecord/test/connections/native_openbase/connection.rb +21 -0
- data/sample_rails_project/vendor/rails/activerecord/test/connections/native_oracle/connection.rb +27 -0
- data/sample_rails_project/vendor/rails/activerecord/test/connections/native_postgresql/connection.rb +23 -0
- data/sample_rails_project/vendor/rails/activerecord/test/connections/native_sqlite/connection.rb +34 -0
- data/sample_rails_project/vendor/rails/activerecord/test/connections/native_sqlite3/connection.rb +34 -0
- data/sample_rails_project/vendor/rails/activerecord/test/connections/native_sqlite3/in_memory_connection.rb +18 -0
- data/sample_rails_project/vendor/rails/activerecord/test/connections/native_sqlserver/connection.rb +23 -0
- data/sample_rails_project/vendor/rails/activerecord/test/connections/native_sqlserver_odbc/connection.rb +25 -0
- data/sample_rails_project/vendor/rails/activerecord/test/connections/native_sybase/connection.rb +23 -0
- data/sample_rails_project/vendor/rails/activerecord/test/copy_table_sqlite.rb +64 -0
- data/sample_rails_project/vendor/rails/activerecord/test/datatype_test_postgresql.rb +52 -0
- data/sample_rails_project/vendor/rails/activerecord/test/default_test_firebird.rb +16 -0
- data/sample_rails_project/vendor/rails/activerecord/test/defaults_test.rb +60 -0
- data/sample_rails_project/vendor/rails/activerecord/test/deprecated_associations_test.rb +396 -0
- data/sample_rails_project/vendor/rails/activerecord/test/deprecated_finder_test.rb +151 -0
- data/sample_rails_project/vendor/rails/activerecord/test/empty_date_time_test.rb +25 -0
- data/sample_rails_project/vendor/rails/activerecord/test/finder_test.rb +504 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/accounts.yml +28 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/author.rb +99 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/author_favorites.yml +4 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/authors.yml +7 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/auto_id.rb +4 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/bad_fixtures/attr_with_numeric_first_char +1 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/bad_fixtures/attr_with_spaces +1 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/bad_fixtures/blank_line +3 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/bad_fixtures/duplicate_attributes +3 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/bad_fixtures/missing_value +1 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/binary.rb +2 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/categories/special_categories.yml +9 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/categories/subsubdir/arbitrary_filename.yml +4 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/categories.yml +14 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/categories_ordered.yml +7 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/categories_posts.yml +23 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/categorization.rb +5 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/categorizations.yml +17 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/category.rb +20 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/column_name.rb +3 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/comment.rb +23 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/comments.yml +59 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/companies.yml +55 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/company.rb +107 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/company_in_module.rb +59 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/computer.rb +3 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/computers.yml +4 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/course.rb +3 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/courses.yml +7 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/customer.rb +55 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/customers.yml +17 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/db_definitions/db2.drop.sql +32 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/db_definitions/db2.sql +231 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/db_definitions/db22.drop.sql +2 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/db_definitions/db22.sql +5 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/db_definitions/firebird.drop.sql +63 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/db_definitions/firebird.sql +304 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/db_definitions/firebird2.drop.sql +2 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/db_definitions/firebird2.sql +6 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/db_definitions/frontbase.drop.sql +32 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/db_definitions/frontbase.sql +268 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/db_definitions/frontbase2.drop.sql +1 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/db_definitions/frontbase2.sql +4 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/db_definitions/mysql.drop.sql +32 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/db_definitions/mysql.sql +234 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/db_definitions/mysql2.drop.sql +2 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/db_definitions/mysql2.sql +5 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/db_definitions/openbase.drop.sql +2 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/db_definitions/openbase.sql +302 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/db_definitions/openbase2.drop.sql +2 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/db_definitions/openbase2.sql +7 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/db_definitions/oracle.drop.sql +65 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/db_definitions/oracle.sql +325 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/db_definitions/oracle2.drop.sql +2 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/db_definitions/oracle2.sql +6 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/db_definitions/postgresql.drop.sql +37 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/db_definitions/postgresql.sql +263 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/db_definitions/postgresql2.drop.sql +2 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/db_definitions/postgresql2.sql +5 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/db_definitions/schema.rb +60 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/db_definitions/sqlite.drop.sql +32 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/db_definitions/sqlite.sql +215 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/db_definitions/sqlite2.drop.sql +2 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/db_definitions/sqlite2.sql +5 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/db_definitions/sqlserver.drop.sql +34 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/db_definitions/sqlserver.sql +243 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/db_definitions/sqlserver2.drop.sql +2 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/db_definitions/sqlserver2.sql +5 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/db_definitions/sybase.drop.sql +34 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/db_definitions/sybase.sql +218 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/db_definitions/sybase2.drop.sql +4 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/db_definitions/sybase2.sql +5 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/default.rb +2 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/developer.rb +52 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/developers.yml +21 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/developers_projects/david_action_controller +3 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/developers_projects/david_active_record +3 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/developers_projects/jamis_active_record +2 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/developers_projects.yml +17 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/edge.rb +5 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/edges.yml +6 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/entrant.rb +3 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/entrants.yml +14 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/fk_test_has_fk.yml +3 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/fk_test_has_pk.yml +2 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/flowers.jpg +0 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/funny_jokes.yml +10 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/joke.rb +6 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/keyboard.rb +3 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/legacy_thing.rb +3 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/legacy_things.yml +3 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/migrations/1_people_have_last_names.rb +9 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/migrations/2_we_need_reminders.rb +12 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/migrations/3_innocent_jointable.rb +12 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/migrations_with_decimal/1_give_me_big_numbers.rb +15 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/migrations_with_duplicate/1_people_have_last_names.rb +9 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/migrations_with_duplicate/2_we_need_reminders.rb +12 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/migrations_with_duplicate/3_foo.rb +7 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/migrations_with_duplicate/3_innocent_jointable.rb +12 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/migrations_with_missing_versions/1000_people_have_middle_names.rb +9 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/migrations_with_missing_versions/1_people_have_last_names.rb +9 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/migrations_with_missing_versions/3_we_need_reminders.rb +12 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/migrations_with_missing_versions/4_innocent_jointable.rb +12 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/mixed_case_monkey.rb +3 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/mixed_case_monkeys.yml +6 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/mixin.rb +63 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/mixins.yml +127 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/movie.rb +5 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/movies.yml +7 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/naked/csv/accounts.csv +1 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/naked/yml/accounts.yml +1 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/naked/yml/companies.yml +1 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/naked/yml/courses.yml +1 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/order.rb +4 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/people.yml +3 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/person.rb +4 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/post.rb +58 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/posts.yml +48 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/project.rb +27 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/projects.yml +7 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/reader.rb +4 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/readers.yml +4 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/reply.rb +37 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/subject.rb +4 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/subscriber.rb +6 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/subscribers/first +2 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/subscribers/second +2 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/tag.rb +7 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/tagging.rb +6 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/taggings.yml +18 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/tags.yml +7 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/task.rb +3 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/tasks.yml +7 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/topic.rb +25 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/topics.yml +22 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/vertex.rb +9 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures/vertices.yml +4 -0
- data/sample_rails_project/vendor/rails/activerecord/test/fixtures_test.rb +401 -0
- data/sample_rails_project/vendor/rails/activerecord/test/inheritance_test.rb +205 -0
- data/sample_rails_project/vendor/rails/activerecord/test/lifecycle_test.rb +137 -0
- data/sample_rails_project/vendor/rails/activerecord/test/locking_test.rb +190 -0
- data/sample_rails_project/vendor/rails/activerecord/test/method_scoping_test.rb +416 -0
- data/sample_rails_project/vendor/rails/activerecord/test/migration_test.rb +768 -0
- data/sample_rails_project/vendor/rails/activerecord/test/migration_test_firebird.rb +124 -0
- data/sample_rails_project/vendor/rails/activerecord/test/mixin_nested_set_test.rb +196 -0
- data/sample_rails_project/vendor/rails/activerecord/test/mixin_test.rb +550 -0
- data/sample_rails_project/vendor/rails/activerecord/test/modules_test.rb +34 -0
- data/sample_rails_project/vendor/rails/activerecord/test/multiple_db_test.rb +60 -0
- data/sample_rails_project/vendor/rails/activerecord/test/pk_test.rb +104 -0
- data/sample_rails_project/vendor/rails/activerecord/test/readonly_test.rb +107 -0
- data/sample_rails_project/vendor/rails/activerecord/test/reflection_test.rb +159 -0
- data/sample_rails_project/vendor/rails/activerecord/test/schema_authorization_test_postgresql.rb +75 -0
- data/sample_rails_project/vendor/rails/activerecord/test/schema_dumper_test.rb +96 -0
- data/sample_rails_project/vendor/rails/activerecord/test/schema_test_postgresql.rb +64 -0
- data/sample_rails_project/vendor/rails/activerecord/test/synonym_test_oracle.rb +17 -0
- data/sample_rails_project/vendor/rails/activerecord/test/table_name_test_sqlserver.rb +23 -0
- data/sample_rails_project/vendor/rails/activerecord/test/threaded_connections_test.rb +48 -0
- data/sample_rails_project/vendor/rails/activerecord/test/transactions_test.rb +230 -0
- data/sample_rails_project/vendor/rails/activerecord/test/unconnected_test.rb +32 -0
- data/sample_rails_project/vendor/rails/activerecord/test/validations_test.rb +1097 -0
- data/sample_rails_project/vendor/rails/activerecord/test/xml_serialization_test.rb +125 -0
- data/sample_rails_project/vendor/rails/activesupport/CHANGELOG +703 -0
- data/sample_rails_project/vendor/rails/activesupport/README +43 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/binding_of_caller.rb +84 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/breakpoint.rb +528 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/caching_tools.rb +62 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/clean_logger.rb +38 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/array/conversions.rb +72 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/array/grouping.rb +55 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/array.rb +7 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/bigdecimal/formatting.rb +7 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/bigdecimal.rb +3 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/blank.rb +50 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/cgi/escape_skipping_slashes.rb +14 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/cgi.rb +5 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/class/attribute_accessors.rb +48 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/class/inheritable_attributes.rb +140 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/class/removal.rb +24 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/class.rb +3 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/date/conversions.rb +39 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/date.rb +6 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/enumerable.rb +62 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/exception.rb +33 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/hash/conversions.rb +155 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/hash/diff.rb +11 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb +88 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/hash/keys.rb +53 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/hash/reverse_merge.rb +25 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/hash.rb +13 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/integer/even_odd.rb +24 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/integer/inflections.rb +21 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/integer.rb +7 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/kernel/agnostics.rb +11 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/kernel/daemonizing.rb +15 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/kernel/reporting.rb +51 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/kernel/requires.rb +24 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/kernel.rb +4 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/load_error.rb +38 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/logger.rb +16 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/module/aliasing.rb +58 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/module/attr_internal.rb +31 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/module/attribute_accessors.rb +48 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/module/delegation.rb +41 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/module/inclusion.rb +11 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/module/introspection.rb +21 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/module/loading.rb +13 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/module.rb +7 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/name_error.rb +17 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/numeric/bytes.rb +44 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/numeric/time.rb +72 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/numeric.rb +7 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/object/extending.rb +47 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/object/misc.rb +34 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/object.rb +2 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/pathname/clean_within.rb +14 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/pathname.rb +7 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/proc.rb +12 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/range/conversions.rb +21 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/range.rb +5 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/string/access.rb +58 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/string/conversions.rb +19 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/string/inflections.rb +153 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/string/iterators.rb +17 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/string/starts_ends_with.rb +20 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/string/unicode.rb +42 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/string.rb +15 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/symbol.rb +12 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb +191 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/time/conversions.rb +33 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext/time.rb +17 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/core_ext.rb +1 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/dependencies.rb +539 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/deprecation.rb +202 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/inflections.rb +52 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/inflector.rb +275 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/json/encoders/core.rb +68 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/json/encoders.rb +25 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/json.rb +48 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/multibyte/chars.rb +129 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/multibyte/generators/generate_tables.rb +149 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/multibyte/handlers/passthru_handler.rb +9 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/multibyte/handlers/utf8_handler.rb +454 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/multibyte/handlers/utf8_handler_proc.rb +43 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/multibyte.rb +7 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/option_merger.rb +25 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/ordered_options.rb +44 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/reloadable.rb +60 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/values/time_zone.rb +180 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/values/unicode_tables.dat +0 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/vendor/builder/blankslate.rb +63 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/vendor/builder/xchar.rb +112 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/vendor/builder/xmlbase.rb +145 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/vendor/builder/xmlevents.rb +63 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/vendor/builder/xmlmarkup.rb +327 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/vendor/builder.rb +13 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/vendor/xml_simple.rb +1021 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/version.rb +9 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support/whiny_nil.rb +38 -0
- data/sample_rails_project/vendor/rails/activesupport/lib/active_support.rb +44 -0
- data/sample_rails_project/vendor/rails/railties/CHANGELOG +1366 -0
- data/sample_rails_project/vendor/rails/railties/MIT-LICENSE +20 -0
- data/sample_rails_project/vendor/rails/railties/README +182 -0
- data/sample_rails_project/vendor/rails/railties/Rakefile +334 -0
- data/sample_rails_project/vendor/rails/railties/bin/about +3 -0
- data/sample_rails_project/vendor/rails/railties/bin/breakpointer +3 -0
- data/sample_rails_project/vendor/rails/railties/bin/console +3 -0
- data/sample_rails_project/vendor/rails/railties/bin/destroy +3 -0
- data/sample_rails_project/vendor/rails/railties/bin/generate +3 -0
- data/sample_rails_project/vendor/rails/railties/bin/performance/benchmarker +3 -0
- data/sample_rails_project/vendor/rails/railties/bin/performance/profiler +3 -0
- data/sample_rails_project/vendor/rails/railties/bin/plugin +3 -0
- data/sample_rails_project/vendor/rails/railties/bin/process/inspector +3 -0
- data/sample_rails_project/vendor/rails/railties/bin/process/reaper +3 -0
- data/sample_rails_project/vendor/rails/railties/bin/process/spawner +3 -0
- data/sample_rails_project/vendor/rails/railties/bin/rails +19 -0
- data/sample_rails_project/vendor/rails/railties/bin/runner +3 -0
- data/sample_rails_project/vendor/rails/railties/bin/server +3 -0
- data/sample_rails_project/vendor/rails/railties/builtin/rails_info/rails/info.rb +123 -0
- data/sample_rails_project/vendor/rails/railties/builtin/rails_info/rails/info_controller.rb +9 -0
- data/sample_rails_project/vendor/rails/railties/builtin/rails_info/rails/info_helper.rb +2 -0
- data/sample_rails_project/vendor/rails/railties/builtin/rails_info/rails_info_controller.rb +2 -0
- data/sample_rails_project/vendor/rails/railties/configs/apache.conf +40 -0
- data/sample_rails_project/vendor/rails/railties/configs/databases/frontbase.yml +28 -0
- data/sample_rails_project/vendor/rails/railties/configs/databases/mysql.yml +48 -0
- data/sample_rails_project/vendor/rails/railties/configs/databases/oracle.yml +39 -0
- data/sample_rails_project/vendor/rails/railties/configs/databases/postgresql.yml +44 -0
- data/sample_rails_project/vendor/rails/railties/configs/databases/sqlite2.yml +16 -0
- data/sample_rails_project/vendor/rails/railties/configs/databases/sqlite3.yml +19 -0
- data/sample_rails_project/vendor/rails/railties/configs/empty.log +0 -0
- data/sample_rails_project/vendor/rails/railties/configs/lighttpd.conf +54 -0
- data/sample_rails_project/vendor/rails/railties/configs/routes.rb +23 -0
- data/sample_rails_project/vendor/rails/railties/dispatches/dispatch.fcgi +24 -0
- data/sample_rails_project/vendor/rails/railties/dispatches/dispatch.rb +10 -0
- data/sample_rails_project/vendor/rails/railties/dispatches/gateway.cgi +97 -0
- data/sample_rails_project/vendor/rails/railties/doc/README_FOR_APP +2 -0
- data/sample_rails_project/vendor/rails/railties/environments/boot.rb +45 -0
- data/sample_rails_project/vendor/rails/railties/environments/development.rb +21 -0
- data/sample_rails_project/vendor/rails/railties/environments/environment.rb +60 -0
- data/sample_rails_project/vendor/rails/railties/environments/production.rb +18 -0
- data/sample_rails_project/vendor/rails/railties/environments/test.rb +19 -0
- data/sample_rails_project/vendor/rails/railties/fresh_rakefile +10 -0
- data/sample_rails_project/vendor/rails/railties/helpers/application.rb +7 -0
- data/sample_rails_project/vendor/rails/railties/helpers/application_helper.rb +3 -0
- data/sample_rails_project/vendor/rails/railties/helpers/test_helper.rb +28 -0
- data/sample_rails_project/vendor/rails/railties/html/404.html +30 -0
- data/sample_rails_project/vendor/rails/railties/html/500.html +30 -0
- data/sample_rails_project/vendor/rails/railties/html/favicon.ico +0 -0
- data/sample_rails_project/vendor/rails/railties/html/images/rails.png +0 -0
- data/sample_rails_project/vendor/rails/railties/html/index.html +277 -0
- data/sample_rails_project/vendor/rails/railties/html/javascripts/application.js +2 -0
- data/sample_rails_project/vendor/rails/railties/html/javascripts/controls.js +833 -0
- data/sample_rails_project/vendor/rails/railties/html/javascripts/dragdrop.js +942 -0
- data/sample_rails_project/vendor/rails/railties/html/javascripts/effects.js +1088 -0
- data/sample_rails_project/vendor/rails/railties/html/javascripts/prototype.js +2515 -0
- data/sample_rails_project/vendor/rails/railties/html/robots.txt +1 -0
- data/sample_rails_project/vendor/rails/railties/lib/binding_of_caller.rb +85 -0
- data/sample_rails_project/vendor/rails/railties/lib/breakpoint.rb +553 -0
- data/sample_rails_project/vendor/rails/railties/lib/breakpoint_client.rb +196 -0
- data/sample_rails_project/vendor/rails/railties/lib/code_statistics.rb +107 -0
- data/sample_rails_project/vendor/rails/railties/lib/commands/about.rb +2 -0
- data/sample_rails_project/vendor/rails/railties/lib/commands/breakpointer.rb +1 -0
- data/sample_rails_project/vendor/rails/railties/lib/commands/console.rb +25 -0
- data/sample_rails_project/vendor/rails/railties/lib/commands/destroy.rb +6 -0
- data/sample_rails_project/vendor/rails/railties/lib/commands/generate.rb +6 -0
- data/sample_rails_project/vendor/rails/railties/lib/commands/ncgi/listener +86 -0
- data/sample_rails_project/vendor/rails/railties/lib/commands/ncgi/tracker +69 -0
- data/sample_rails_project/vendor/rails/railties/lib/commands/performance/benchmarker.rb +24 -0
- data/sample_rails_project/vendor/rails/railties/lib/commands/performance/profiler.rb +50 -0
- data/sample_rails_project/vendor/rails/railties/lib/commands/plugin.rb +918 -0
- data/sample_rails_project/vendor/rails/railties/lib/commands/process/inspector.rb +68 -0
- data/sample_rails_project/vendor/rails/railties/lib/commands/process/reaper.rb +149 -0
- data/sample_rails_project/vendor/rails/railties/lib/commands/process/spawner.rb +209 -0
- data/sample_rails_project/vendor/rails/railties/lib/commands/process/spinner.rb +57 -0
- data/sample_rails_project/vendor/rails/railties/lib/commands/runner.rb +48 -0
- data/sample_rails_project/vendor/rails/railties/lib/commands/server.rb +39 -0
- data/sample_rails_project/vendor/rails/railties/lib/commands/servers/base.rb +19 -0
- data/sample_rails_project/vendor/rails/railties/lib/commands/servers/lighttpd.rb +94 -0
- data/sample_rails_project/vendor/rails/railties/lib/commands/servers/mongrel.rb +65 -0
- data/sample_rails_project/vendor/rails/railties/lib/commands/servers/webrick.rb +59 -0
- data/sample_rails_project/vendor/rails/railties/lib/commands/update.rb +4 -0
- data/sample_rails_project/vendor/rails/railties/lib/commands.rb +17 -0
- data/sample_rails_project/vendor/rails/railties/lib/console_app.rb +27 -0
- data/sample_rails_project/vendor/rails/railties/lib/console_sandbox.rb +6 -0
- data/sample_rails_project/vendor/rails/railties/lib/console_with_helpers.rb +23 -0
- data/sample_rails_project/vendor/rails/railties/lib/dispatcher.rb +173 -0
- data/sample_rails_project/vendor/rails/railties/lib/fcgi_handler.rb +225 -0
- data/sample_rails_project/vendor/rails/railties/lib/initializer.rb +702 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails/version.rb +9 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/base.rb +261 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/commands.rb +581 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generated_attribute.rb +42 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/applications/app/USAGE +16 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/applications/app/app_generator.rb +160 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/controller/USAGE +30 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/controller/controller_generator.rb +37 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/controller/templates/controller.rb +10 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/controller/templates/functional_test.rb +18 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/controller/templates/helper.rb +2 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/controller/templates/view.rhtml +2 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/integration_test/USAGE +14 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/integration_test/integration_test_generator.rb +16 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/integration_test/templates/integration_test.rb +10 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/mailer/USAGE +18 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/mailer/mailer_generator.rb +34 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/mailer/templates/fixture.rhtml +3 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/mailer/templates/mailer.rb +13 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/mailer/templates/unit_test.rb +37 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/mailer/templates/view.rhtml +3 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/migration/USAGE +14 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/migration/migration_generator.rb +7 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/migration/templates/migration.rb +7 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/model/USAGE +26 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/model/model_generator.rb +38 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/model/templates/fixtures.yml +11 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/model/templates/migration.rb +13 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/model/templates/model.rb +2 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/model/templates/unit_test.rb +10 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/observer/USAGE +15 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/observer/observer_generator.rb +16 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/observer/templates/observer.rb +2 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/observer/templates/unit_test.rb +10 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/plugin/USAGE +35 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/plugin/plugin_generator.rb +38 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/README +4 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/Rakefile +22 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/USAGE +8 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/generator.rb +8 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/init.rb +1 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/install.rb +1 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/plugin.rb +1 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/tasks.rake +4 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/uninstall.rb +1 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/unit_test.rb +8 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/resource/resource_generator.rb +76 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/resource/templates/USAGE +18 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/resource/templates/controller.rb +2 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/resource/templates/fixtures.yml +11 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/resource/templates/functional_test.rb +20 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/resource/templates/helper.rb +2 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/resource/templates/migration.rb +13 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/resource/templates/model.rb +2 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/resource/templates/unit_test.rb +10 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/USAGE +32 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb +193 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/controller.rb +58 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/form.rhtml +3 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/form_scaffolding.rhtml +1 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/functional_test.rb +102 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/helper.rb +2 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/layout.rhtml +17 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/style.css +74 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/view_edit.rhtml +9 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/view_list.rhtml +27 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/view_new.rhtml +8 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/view_show.rhtml +8 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/scaffold_resource/USAGE +29 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/scaffold_resource/scaffold_resource_generator.rb +92 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/scaffold_resource/templates/controller.rb +79 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/scaffold_resource/templates/fixtures.yml +11 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/scaffold_resource/templates/functional_test.rb +57 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/scaffold_resource/templates/helper.rb +2 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/scaffold_resource/templates/layout.rhtml +17 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/scaffold_resource/templates/migration.rb +13 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/scaffold_resource/templates/model.rb +2 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/scaffold_resource/templates/style.css +74 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/scaffold_resource/templates/unit_test.rb +10 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/scaffold_resource/templates/view_edit.rhtml +19 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/scaffold_resource/templates/view_index.rhtml +24 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/scaffold_resource/templates/view_new.rhtml +18 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/scaffold_resource/templates/view_show.rhtml +10 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/session_migration/USAGE +15 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/session_migration/session_migration_generator.rb +18 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/session_migration/templates/migration.rb +16 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/web_service/USAGE +28 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/web_service/templates/api_definition.rb +5 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/web_service/templates/controller.rb +8 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/web_service/templates/functional_test.rb +19 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/generators/components/web_service/web_service_generator.rb +29 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/lookup.rb +209 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/manifest.rb +53 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/options.rb +143 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/scripts/destroy.rb +7 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/scripts/generate.rb +7 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/scripts/update.rb +12 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/scripts.rb +83 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/simple_logger.rb +46 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator/spec.rb +44 -0
- data/sample_rails_project/vendor/rails/railties/lib/rails_generator.rb +43 -0
- data/sample_rails_project/vendor/rails/railties/lib/railties_path.rb +1 -0
- data/sample_rails_project/vendor/rails/railties/lib/ruby_version_check.rb +17 -0
- data/sample_rails_project/vendor/rails/railties/lib/rubyprof_ext.rb +35 -0
- data/sample_rails_project/vendor/rails/railties/lib/tasks/databases.rake +187 -0
- data/sample_rails_project/vendor/rails/railties/lib/tasks/documentation.rake +82 -0
- data/sample_rails_project/vendor/rails/railties/lib/tasks/framework.rake +112 -0
- data/sample_rails_project/vendor/rails/railties/lib/tasks/log.rake +9 -0
- data/sample_rails_project/vendor/rails/railties/lib/tasks/misc.rake +4 -0
- data/sample_rails_project/vendor/rails/railties/lib/tasks/pre_namespace_aliases.rake +53 -0
- data/sample_rails_project/vendor/rails/railties/lib/tasks/rails.rb +8 -0
- data/sample_rails_project/vendor/rails/railties/lib/tasks/statistics.rake +18 -0
- data/sample_rails_project/vendor/rails/railties/lib/tasks/testing.rake +120 -0
- data/sample_rails_project/vendor/rails/railties/lib/tasks/tmp.rake +37 -0
- data/sample_rails_project/vendor/rails/railties/lib/test_help.rb +19 -0
- data/sample_rails_project/vendor/rails/railties/lib/webrick_server.rb +166 -0
- data/spec/deep_test/options_spec.rb +204 -0
- data/spec/deep_test/spec/extensions/example_group_methods_spec.rb +48 -0
- data/spec/deep_test/spec/extensions/example_methods_spec.rb +62 -0
- data/spec/deep_test/spec/extensions/options_spec.rb +23 -0
- data/spec/deep_test/spec/extensions/reporter_spec.rb +28 -0
- data/spec/deep_test/spec/extensions/spec_task_spec.rb +34 -0
- data/spec/deep_test/spec/runner_spec.rb +133 -0
- data/spec/deep_test/spec/work_result_spec.rb +14 -0
- data/spec/deep_test/spec/work_unit_spec.rb +78 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +67 -0
- data/test/deep_test/agent_test.rb +175 -0
- data/test/deep_test/central_command_test.rb +147 -0
- data/test/deep_test/cpu_info_test.rb +33 -0
- data/test/deep_test/database/mysql_setup_listener_test.rb +18 -0
- data/test/deep_test/demon_test.rb +23 -0
- data/test/deep_test/distributed/beachhead_test.rb +67 -0
- data/test/deep_test/distributed/dispatch_controller_test.rb +162 -0
- data/test/deep_test/distributed/filename_resolver_test.rb +56 -0
- data/test/deep_test/distributed/landing_fleet_test.rb +55 -0
- data/test/deep_test/distributed/landing_ship_test.rb +48 -0
- data/test/deep_test/distributed/remote_deployment_test.rb +134 -0
- data/test/deep_test/distributed/rsync_test.rb +47 -0
- data/test/deep_test/distributed/shell_environment_fixtures/set_bar_to_foo +1 -0
- data/test/deep_test/distributed/shell_environment_fixtures/set_foo_to_bar +1 -0
- data/test/deep_test/distributed/shell_environment_fixtures/set_foo_to_baz +1 -0
- data/test/deep_test/distributed/shell_environment_test.rb +108 -0
- data/test/deep_test/distributed/ssh_client_connection_info_test.rb +34 -0
- data/test/deep_test/extensions/object_extension_test.rb +37 -0
- data/test/deep_test/listener_list_test.rb +22 -0
- data/test/deep_test/local_deployment_test.rb +19 -0
- data/test/deep_test/logger_test.rb +38 -0
- data/test/deep_test/main_test.rb +12 -0
- data/test/deep_test/marshallable_exception_wrapper_test.rb +46 -0
- data/test/deep_test/metrics/data_test.rb +22 -0
- data/test/deep_test/metrics/measurement_test.rb +18 -0
- data/test/deep_test/proxy_io_test.rb +104 -0
- data/test/deep_test/result_reader_test.rb +128 -0
- data/test/deep_test/test/extensions/error_test.rb +42 -0
- data/test/deep_test/test/runner_test.rb +11 -0
- data/test/deep_test/test/supervised_test_suite_test.rb +107 -0
- data/test/deep_test/test/work_result_test.rb +85 -0
- data/test/deep_test/test/work_unit_test.rb +63 -0
- data/test/deep_test/test_task_test.rb +15 -0
- data/test/deep_test/ui/console_test.rb +13 -0
- data/test/deep_test/warlock_test.rb +40 -0
- data/test/test_helper.rb +30 -0
- data/test/test_task_test.rb +75 -0
- metadata +1447 -0
@@ -0,0 +1,2164 @@
|
|
1
|
+
require 'base64'
|
2
|
+
require 'yaml'
|
3
|
+
require 'set'
|
4
|
+
require 'active_record/deprecated_finders'
|
5
|
+
|
6
|
+
module ActiveRecord #:nodoc:
|
7
|
+
class ActiveRecordError < StandardError #:nodoc:
|
8
|
+
end
|
9
|
+
class SubclassNotFound < ActiveRecordError #:nodoc:
|
10
|
+
end
|
11
|
+
class AssociationTypeMismatch < ActiveRecordError #:nodoc:
|
12
|
+
end
|
13
|
+
class SerializationTypeMismatch < ActiveRecordError #:nodoc:
|
14
|
+
end
|
15
|
+
class AdapterNotSpecified < ActiveRecordError # :nodoc:
|
16
|
+
end
|
17
|
+
class AdapterNotFound < ActiveRecordError # :nodoc:
|
18
|
+
end
|
19
|
+
class ConnectionNotEstablished < ActiveRecordError #:nodoc:
|
20
|
+
end
|
21
|
+
class ConnectionFailed < ActiveRecordError #:nodoc:
|
22
|
+
end
|
23
|
+
class RecordNotFound < ActiveRecordError #:nodoc:
|
24
|
+
end
|
25
|
+
class RecordNotSaved < ActiveRecordError #:nodoc:
|
26
|
+
end
|
27
|
+
class StatementInvalid < ActiveRecordError #:nodoc:
|
28
|
+
end
|
29
|
+
class PreparedStatementInvalid < ActiveRecordError #:nodoc:
|
30
|
+
end
|
31
|
+
class StaleObjectError < ActiveRecordError #:nodoc:
|
32
|
+
end
|
33
|
+
class ConfigurationError < StandardError #:nodoc:
|
34
|
+
end
|
35
|
+
class ReadOnlyRecord < StandardError #:nodoc:
|
36
|
+
end
|
37
|
+
|
38
|
+
class AttributeAssignmentError < ActiveRecordError #:nodoc:
|
39
|
+
attr_reader :exception, :attribute
|
40
|
+
def initialize(message, exception, attribute)
|
41
|
+
@exception = exception
|
42
|
+
@attribute = attribute
|
43
|
+
@message = message
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
class MultiparameterAssignmentErrors < ActiveRecordError #:nodoc:
|
48
|
+
attr_reader :errors
|
49
|
+
def initialize(errors)
|
50
|
+
@errors = errors
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
# Active Record objects don't specify their attributes directly, but rather infer them from the table definition with
|
55
|
+
# which they're linked. Adding, removing, and changing attributes and their type is done directly in the database. Any change
|
56
|
+
# is instantly reflected in the Active Record objects. The mapping that binds a given Active Record class to a certain
|
57
|
+
# database table will happen automatically in most common cases, but can be overwritten for the uncommon ones.
|
58
|
+
#
|
59
|
+
# See the mapping rules in table_name and the full example in link:files/README.html for more insight.
|
60
|
+
#
|
61
|
+
# == Creation
|
62
|
+
#
|
63
|
+
# Active Records accept constructor parameters either in a hash or as a block. The hash method is especially useful when
|
64
|
+
# you're receiving the data from somewhere else, like a HTTP request. It works like this:
|
65
|
+
#
|
66
|
+
# user = User.new(:name => "David", :occupation => "Code Artist")
|
67
|
+
# user.name # => "David"
|
68
|
+
#
|
69
|
+
# You can also use block initialization:
|
70
|
+
#
|
71
|
+
# user = User.new do |u|
|
72
|
+
# u.name = "David"
|
73
|
+
# u.occupation = "Code Artist"
|
74
|
+
# end
|
75
|
+
#
|
76
|
+
# And of course you can just create a bare object and specify the attributes after the fact:
|
77
|
+
#
|
78
|
+
# user = User.new
|
79
|
+
# user.name = "David"
|
80
|
+
# user.occupation = "Code Artist"
|
81
|
+
#
|
82
|
+
# == Conditions
|
83
|
+
#
|
84
|
+
# Conditions can either be specified as a string, array, or hash representing the WHERE-part of an SQL statement.
|
85
|
+
# The array form is to be used when the condition input is tainted and requires sanitization. The string form can
|
86
|
+
# be used for statements that don't involve tainted data. The hash form works much like the array form, except
|
87
|
+
# only equality and range is possible. Examples:
|
88
|
+
#
|
89
|
+
# class User < ActiveRecord::Base
|
90
|
+
# def self.authenticate_unsafely(user_name, password)
|
91
|
+
# find(:first, :conditions => "user_name = '#{user_name}' AND password = '#{password}'")
|
92
|
+
# end
|
93
|
+
#
|
94
|
+
# def self.authenticate_safely(user_name, password)
|
95
|
+
# find(:first, :conditions => [ "user_name = ? AND password = ?", user_name, password ])
|
96
|
+
# end
|
97
|
+
#
|
98
|
+
# def self.authenticate_safely_simply(user_name, password)
|
99
|
+
# find(:first, :conditions => { :user_name => user_name, :password => password })
|
100
|
+
# end
|
101
|
+
# end
|
102
|
+
#
|
103
|
+
# The <tt>authenticate_unsafely</tt> method inserts the parameters directly into the query and is thus susceptible to SQL-injection
|
104
|
+
# attacks if the <tt>user_name</tt> and +password+ parameters come directly from a HTTP request. The <tt>authenticate_safely</tt> and
|
105
|
+
# <tt>authenticate_safely_simply</tt> both will sanitize the <tt>user_name</tt> and +password+ before inserting them in the query,
|
106
|
+
# which will ensure that an attacker can't escape the query and fake the login (or worse).
|
107
|
+
#
|
108
|
+
# When using multiple parameters in the conditions, it can easily become hard to read exactly what the fourth or fifth
|
109
|
+
# question mark is supposed to represent. In those cases, you can resort to named bind variables instead. That's done by replacing
|
110
|
+
# the question marks with symbols and supplying a hash with values for the matching symbol keys:
|
111
|
+
#
|
112
|
+
# Company.find(:first, [
|
113
|
+
# "id = :id AND name = :name AND division = :division AND created_at > :accounting_date",
|
114
|
+
# { :id => 3, :name => "37signals", :division => "First", :accounting_date => '2005-01-01' }
|
115
|
+
# ])
|
116
|
+
#
|
117
|
+
# Similarly, a simple hash without a statement will generate conditions based on equality with the SQL AND
|
118
|
+
# operator. For instance:
|
119
|
+
#
|
120
|
+
# Student.find(:all, :conditions => { :first_name => "Harvey", :status => 1 })
|
121
|
+
# Student.find(:all, :conditions => params[:student])
|
122
|
+
#
|
123
|
+
# A range may be used in the hash to use the SQL BETWEEN operator:
|
124
|
+
#
|
125
|
+
# Student.find(:all, :conditions => { :grade => 9..12 })
|
126
|
+
#
|
127
|
+
# == Overwriting default accessors
|
128
|
+
#
|
129
|
+
# All column values are automatically available through basic accessors on the Active Record object, but some times you
|
130
|
+
# want to specialize this behavior. This can be done by either by overwriting the default accessors (using the same
|
131
|
+
# name as the attribute) calling read_attribute(attr_name) and write_attribute(attr_name, value) to actually change things.
|
132
|
+
# Example:
|
133
|
+
#
|
134
|
+
# class Song < ActiveRecord::Base
|
135
|
+
# # Uses an integer of seconds to hold the length of the song
|
136
|
+
#
|
137
|
+
# def length=(minutes)
|
138
|
+
# write_attribute(:length, minutes * 60)
|
139
|
+
# end
|
140
|
+
#
|
141
|
+
# def length
|
142
|
+
# read_attribute(:length) / 60
|
143
|
+
# end
|
144
|
+
# end
|
145
|
+
#
|
146
|
+
# You can alternatively use self[:attribute]=(value) and self[:attribute] instead of write_attribute(:attribute, vaule) and
|
147
|
+
# read_attribute(:attribute) as a shorter form.
|
148
|
+
#
|
149
|
+
# == Accessing attributes before they have been typecasted
|
150
|
+
#
|
151
|
+
# Sometimes you want to be able to read the raw attribute data without having the column-determined typecast run its course first.
|
152
|
+
# That can be done by using the <attribute>_before_type_cast accessors that all attributes have. For example, if your Account model
|
153
|
+
# has a balance attribute, you can call account.balance_before_type_cast or account.id_before_type_cast.
|
154
|
+
#
|
155
|
+
# This is especially useful in validation situations where the user might supply a string for an integer field and you want to display
|
156
|
+
# the original string back in an error message. Accessing the attribute normally would typecast the string to 0, which isn't what you
|
157
|
+
# want.
|
158
|
+
#
|
159
|
+
# == Dynamic attribute-based finders
|
160
|
+
#
|
161
|
+
# Dynamic attribute-based finders are a cleaner way of getting (and/or creating) objects by simple queries without turning to SQL. They work by
|
162
|
+
# appending the name of an attribute to <tt>find_by_</tt> or <tt>find_all_by_</tt>, so you get finders like Person.find_by_user_name,
|
163
|
+
# Person.find_all_by_last_name, Payment.find_by_transaction_id. So instead of writing
|
164
|
+
# <tt>Person.find(:first, ["user_name = ?", user_name])</tt>, you just do <tt>Person.find_by_user_name(user_name)</tt>.
|
165
|
+
# And instead of writing <tt>Person.find(:all, ["last_name = ?", last_name])</tt>, you just do <tt>Person.find_all_by_last_name(last_name)</tt>.
|
166
|
+
#
|
167
|
+
# It's also possible to use multiple attributes in the same find by separating them with "_and_", so you get finders like
|
168
|
+
# <tt>Person.find_by_user_name_and_password</tt> or even <tt>Payment.find_by_purchaser_and_state_and_country</tt>. So instead of writing
|
169
|
+
# <tt>Person.find(:first, ["user_name = ? AND password = ?", user_name, password])</tt>, you just do
|
170
|
+
# <tt>Person.find_by_user_name_and_password(user_name, password)</tt>.
|
171
|
+
#
|
172
|
+
# It's even possible to use all the additional parameters to find. For example, the full interface for Payment.find_all_by_amount
|
173
|
+
# is actually Payment.find_all_by_amount(amount, options). And the full interface to Person.find_by_user_name is
|
174
|
+
# actually Person.find_by_user_name(user_name, options). So you could call <tt>Payment.find_all_by_amount(50, :order => "created_on")</tt>.
|
175
|
+
#
|
176
|
+
# The same dynamic finder style can be used to create the object if it doesn't already exist. This dynamic finder is called with
|
177
|
+
# <tt>find_or_create_by_</tt> and will return the object if it already exists and otherwise creates it, then returns it. Example:
|
178
|
+
#
|
179
|
+
# # No 'Summer' tag exists
|
180
|
+
# Tag.find_or_create_by_name("Summer") # equal to Tag.create(:name => "Summer")
|
181
|
+
#
|
182
|
+
# # Now the 'Summer' tag does exist
|
183
|
+
# Tag.find_or_create_by_name("Summer") # equal to Tag.find_by_name("Summer")
|
184
|
+
#
|
185
|
+
# Use the <tt>find_or_initialize_by_</tt> finder if you want to return a new record without saving it first. Example:
|
186
|
+
#
|
187
|
+
# # No 'Winter' tag exists
|
188
|
+
# winter = Tag.find_or_initialize_by_name("Winter")
|
189
|
+
# winter.new_record? # true
|
190
|
+
#
|
191
|
+
# == Saving arrays, hashes, and other non-mappable objects in text columns
|
192
|
+
#
|
193
|
+
# Active Record can serialize any object in text columns using YAML. To do so, you must specify this with a call to the class method +serialize+.
|
194
|
+
# This makes it possible to store arrays, hashes, and other non-mappable objects without doing any additional work. Example:
|
195
|
+
#
|
196
|
+
# class User < ActiveRecord::Base
|
197
|
+
# serialize :preferences
|
198
|
+
# end
|
199
|
+
#
|
200
|
+
# user = User.create(:preferences => { "background" => "black", "display" => large })
|
201
|
+
# User.find(user.id).preferences # => { "background" => "black", "display" => large }
|
202
|
+
#
|
203
|
+
# You can also specify a class option as the second parameter that'll raise an exception if a serialized object is retrieved as a
|
204
|
+
# descendent of a class not in the hierarchy. Example:
|
205
|
+
#
|
206
|
+
# class User < ActiveRecord::Base
|
207
|
+
# serialize :preferences, Hash
|
208
|
+
# end
|
209
|
+
#
|
210
|
+
# user = User.create(:preferences => %w( one two three ))
|
211
|
+
# User.find(user.id).preferences # raises SerializationTypeMismatch
|
212
|
+
#
|
213
|
+
# == Single table inheritance
|
214
|
+
#
|
215
|
+
# Active Record allows inheritance by storing the name of the class in a column that by default is called "type" (can be changed
|
216
|
+
# by overwriting <tt>Base.inheritance_column</tt>). This means that an inheritance looking like this:
|
217
|
+
#
|
218
|
+
# class Company < ActiveRecord::Base; end
|
219
|
+
# class Firm < Company; end
|
220
|
+
# class Client < Company; end
|
221
|
+
# class PriorityClient < Client; end
|
222
|
+
#
|
223
|
+
# When you do Firm.create(:name => "37signals"), this record will be saved in the companies table with type = "Firm". You can then
|
224
|
+
# fetch this row again using Company.find(:first, "name = '37signals'") and it will return a Firm object.
|
225
|
+
#
|
226
|
+
# If you don't have a type column defined in your table, single-table inheritance won't be triggered. In that case, it'll work just
|
227
|
+
# like normal subclasses with no special magic for differentiating between them or reloading the right type with find.
|
228
|
+
#
|
229
|
+
# Note, all the attributes for all the cases are kept in the same table. Read more:
|
230
|
+
# http://www.martinfowler.com/eaaCatalog/singleTableInheritance.html
|
231
|
+
#
|
232
|
+
# == Connection to multiple databases in different models
|
233
|
+
#
|
234
|
+
# Connections are usually created through ActiveRecord::Base.establish_connection and retrieved by ActiveRecord::Base.connection.
|
235
|
+
# All classes inheriting from ActiveRecord::Base will use this connection. But you can also set a class-specific connection.
|
236
|
+
# For example, if Course is a ActiveRecord::Base, but resides in a different database you can just say Course.establish_connection
|
237
|
+
# and Course *and all its subclasses* will use this connection instead.
|
238
|
+
#
|
239
|
+
# This feature is implemented by keeping a connection pool in ActiveRecord::Base that is a Hash indexed by the class. If a connection is
|
240
|
+
# requested, the retrieve_connection method will go up the class-hierarchy until a connection is found in the connection pool.
|
241
|
+
#
|
242
|
+
# == Exceptions
|
243
|
+
#
|
244
|
+
# * +ActiveRecordError+ -- generic error class and superclass of all other errors raised by Active Record
|
245
|
+
# * +AdapterNotSpecified+ -- the configuration hash used in <tt>establish_connection</tt> didn't include a
|
246
|
+
# <tt>:adapter</tt> key.
|
247
|
+
# * +AdapterNotFound+ -- the <tt>:adapter</tt> key used in <tt>establish_connection</tt> specified an non-existent adapter
|
248
|
+
# (or a bad spelling of an existing one).
|
249
|
+
# * +AssociationTypeMismatch+ -- the object assigned to the association wasn't of the type specified in the association definition.
|
250
|
+
# * +SerializationTypeMismatch+ -- the object serialized wasn't of the class specified as the second parameter.
|
251
|
+
# * +ConnectionNotEstablished+ -- no connection has been established. Use <tt>establish_connection</tt> before querying.
|
252
|
+
# * +RecordNotFound+ -- no record responded to the find* method.
|
253
|
+
# Either the row with the given ID doesn't exist or the row didn't meet the additional restrictions.
|
254
|
+
# * +StatementInvalid+ -- the database server rejected the SQL statement. The precise error is added in the message.
|
255
|
+
# Either the record with the given ID doesn't exist or the record didn't meet the additional restrictions.
|
256
|
+
# * +MultiparameterAssignmentErrors+ -- collection of errors that occurred during a mass assignment using the
|
257
|
+
# +attributes=+ method. The +errors+ property of this exception contains an array of +AttributeAssignmentError+
|
258
|
+
# objects that should be inspected to determine which attributes triggered the errors.
|
259
|
+
# * +AttributeAssignmentError+ -- an error occurred while doing a mass assignment through the +attributes=+ method.
|
260
|
+
# You can inspect the +attribute+ property of the exception object to determine which attribute triggered the error.
|
261
|
+
#
|
262
|
+
# *Note*: The attributes listed are class-level attributes (accessible from both the class and instance level).
|
263
|
+
# So it's possible to assign a logger to the class through Base.logger= which will then be used by all
|
264
|
+
# instances in the current object space.
|
265
|
+
class Base
|
266
|
+
# Accepts a logger conforming to the interface of Log4r or the default Ruby 1.8+ Logger class, which is then passed
|
267
|
+
# on to any new database connections made and which can be retrieved on both a class and instance level by calling +logger+.
|
268
|
+
cattr_accessor :logger, :instance_writer => false
|
269
|
+
|
270
|
+
include Reloadable::Deprecated
|
271
|
+
|
272
|
+
def self.inherited(child) #:nodoc:
|
273
|
+
@@subclasses[self] ||= []
|
274
|
+
@@subclasses[self] << child
|
275
|
+
super
|
276
|
+
end
|
277
|
+
|
278
|
+
def self.reset_subclasses #:nodoc:
|
279
|
+
nonreloadables = []
|
280
|
+
subclasses.each do |klass|
|
281
|
+
unless Dependencies.autoloaded? klass
|
282
|
+
nonreloadables << klass
|
283
|
+
next
|
284
|
+
end
|
285
|
+
klass.instance_variables.each { |var| klass.send(:remove_instance_variable, var) }
|
286
|
+
klass.instance_methods(false).each { |m| klass.send :undef_method, m }
|
287
|
+
end
|
288
|
+
@@subclasses = {}
|
289
|
+
nonreloadables.each { |klass| (@@subclasses[klass.superclass] ||= []) << klass }
|
290
|
+
end
|
291
|
+
|
292
|
+
@@subclasses = {}
|
293
|
+
|
294
|
+
cattr_accessor :configurations, :instance_writer => false
|
295
|
+
@@configurations = {}
|
296
|
+
|
297
|
+
# Accessor for the prefix type that will be prepended to every primary key column name. The options are :table_name and
|
298
|
+
# :table_name_with_underscore. If the first is specified, the Product class will look for "productid" instead of "id" as
|
299
|
+
# the primary column. If the latter is specified, the Product class will look for "product_id" instead of "id". Remember
|
300
|
+
# that this is a global setting for all Active Records.
|
301
|
+
cattr_accessor :primary_key_prefix_type, :instance_writer => false
|
302
|
+
@@primary_key_prefix_type = nil
|
303
|
+
|
304
|
+
# Accessor for the name of the prefix string to prepend to every table name. So if set to "basecamp_", all
|
305
|
+
# table names will be named like "basecamp_projects", "basecamp_people", etc. This is a convenient way of creating a namespace
|
306
|
+
# for tables in a shared database. By default, the prefix is the empty string.
|
307
|
+
cattr_accessor :table_name_prefix, :instance_writer => false
|
308
|
+
@@table_name_prefix = ""
|
309
|
+
|
310
|
+
# Works like +table_name_prefix+, but appends instead of prepends (set to "_basecamp" gives "projects_basecamp",
|
311
|
+
# "people_basecamp"). By default, the suffix is the empty string.
|
312
|
+
cattr_accessor :table_name_suffix, :instance_writer => false
|
313
|
+
@@table_name_suffix = ""
|
314
|
+
|
315
|
+
# Indicates whether or not table names should be the pluralized versions of the corresponding class names.
|
316
|
+
# If true, the default table name for a +Product+ class will be +products+. If false, it would just be +product+.
|
317
|
+
# See table_name for the full rules on table/class naming. This is true, by default.
|
318
|
+
cattr_accessor :pluralize_table_names, :instance_writer => false
|
319
|
+
@@pluralize_table_names = true
|
320
|
+
|
321
|
+
# Determines whether or not to use ANSI codes to colorize the logging statements committed by the connection adapter. These colors
|
322
|
+
# make it much easier to overview things during debugging (when used through a reader like +tail+ and on a black background), but
|
323
|
+
# may complicate matters if you use software like syslog. This is true, by default.
|
324
|
+
cattr_accessor :colorize_logging, :instance_writer => false
|
325
|
+
@@colorize_logging = true
|
326
|
+
|
327
|
+
# Determines whether to use Time.local (using :local) or Time.utc (using :utc) when pulling dates and times from the database.
|
328
|
+
# This is set to :local by default.
|
329
|
+
cattr_accessor :default_timezone, :instance_writer => false
|
330
|
+
@@default_timezone = :local
|
331
|
+
|
332
|
+
# Determines whether or not to use a connection for each thread, or a single shared connection for all threads.
|
333
|
+
# Defaults to false. Set to true if you're writing a threaded application.
|
334
|
+
cattr_accessor :allow_concurrency, :instance_writer => false
|
335
|
+
@@allow_concurrency = false
|
336
|
+
|
337
|
+
# Determines whether to speed up access by generating optimized reader
|
338
|
+
# methods to avoid expensive calls to method_missing when accessing
|
339
|
+
# attributes by name. You might want to set this to false in development
|
340
|
+
# mode, because the methods would be regenerated on each request.
|
341
|
+
cattr_accessor :generate_read_methods, :instance_writer => false
|
342
|
+
@@generate_read_methods = true
|
343
|
+
|
344
|
+
# Specifies the format to use when dumping the database schema with Rails'
|
345
|
+
# Rakefile. If :sql, the schema is dumped as (potentially database-
|
346
|
+
# specific) SQL statements. If :ruby, the schema is dumped as an
|
347
|
+
# ActiveRecord::Schema file which can be loaded into any database that
|
348
|
+
# supports migrations. Use :ruby if you want to have different database
|
349
|
+
# adapters for, e.g., your development and test environments.
|
350
|
+
cattr_accessor :schema_format , :instance_writer => false
|
351
|
+
@@schema_format = :ruby
|
352
|
+
|
353
|
+
class << self # Class methods
|
354
|
+
# Find operates with three different retrieval approaches:
|
355
|
+
#
|
356
|
+
# * Find by id: This can either be a specific id (1), a list of ids (1, 5, 6), or an array of ids ([5, 6, 10]).
|
357
|
+
# If no record can be found for all of the listed ids, then RecordNotFound will be raised.
|
358
|
+
# * Find first: This will return the first record matched by the options used. These options can either be specific
|
359
|
+
# conditions or merely an order. If no record can matched, nil is returned.
|
360
|
+
# * Find all: This will return all the records matched by the options used. If no records are found, an empty array is returned.
|
361
|
+
#
|
362
|
+
# All approaches accept an option hash as their last parameter. The options are:
|
363
|
+
#
|
364
|
+
# * <tt>:conditions</tt>: An SQL fragment like "administrator = 1" or [ "user_name = ?", username ]. See conditions in the intro.
|
365
|
+
# * <tt>:order</tt>: An SQL fragment like "created_at DESC, name".
|
366
|
+
# * <tt>:group</tt>: An attribute name by which the result should be grouped. Uses the GROUP BY SQL-clause.
|
367
|
+
# * <tt>:limit</tt>: An integer determining the limit on the number of rows that should be returned.
|
368
|
+
# * <tt>:offset</tt>: An integer determining the offset from where the rows should be fetched. So at 5, it would skip the first 4 rows.
|
369
|
+
# * <tt>:joins</tt>: An SQL fragment for additional joins like "LEFT JOIN comments ON comments.post_id = id". (Rarely needed).
|
370
|
+
# The records will be returned read-only since they will have attributes that do not correspond to the table's columns.
|
371
|
+
# Pass :readonly => false to override.
|
372
|
+
# * <tt>:include</tt>: Names associations that should be loaded alongside using LEFT OUTER JOINs. The symbols named refer
|
373
|
+
# to already defined associations. See eager loading under Associations.
|
374
|
+
# * <tt>:select</tt>: By default, this is * as in SELECT * FROM, but can be changed if you for example want to do a join, but not
|
375
|
+
# include the joined columns.
|
376
|
+
# * <tt>:from</tt>: By default, this is the table name of the class, but can be changed to an alternate table name (or even the name
|
377
|
+
# of a database view).
|
378
|
+
# * <tt>:readonly</tt>: Mark the returned records read-only so they cannot be saved or updated.
|
379
|
+
# * <tt>:lock</tt>: An SQL fragment like "FOR UPDATE" or "LOCK IN SHARE MODE".
|
380
|
+
# :lock => true gives connection's default exclusive lock, usually "FOR UPDATE".
|
381
|
+
#
|
382
|
+
# Examples for find by id:
|
383
|
+
# Person.find(1) # returns the object for ID = 1
|
384
|
+
# Person.find(1, 2, 6) # returns an array for objects with IDs in (1, 2, 6)
|
385
|
+
# Person.find([7, 17]) # returns an array for objects with IDs in (7, 17)
|
386
|
+
# Person.find([1]) # returns an array for objects the object with ID = 1
|
387
|
+
# Person.find(1, :conditions => "administrator = 1", :order => "created_on DESC")
|
388
|
+
#
|
389
|
+
# Examples for find first:
|
390
|
+
# Person.find(:first) # returns the first object fetched by SELECT * FROM people
|
391
|
+
# Person.find(:first, :conditions => [ "user_name = ?", user_name])
|
392
|
+
# Person.find(:first, :order => "created_on DESC", :offset => 5)
|
393
|
+
#
|
394
|
+
# Examples for find all:
|
395
|
+
# Person.find(:all) # returns an array of objects for all the rows fetched by SELECT * FROM people
|
396
|
+
# Person.find(:all, :conditions => [ "category IN (?)", categories], :limit => 50)
|
397
|
+
# Person.find(:all, :offset => 10, :limit => 10)
|
398
|
+
# Person.find(:all, :include => [ :account, :friends ])
|
399
|
+
# Person.find(:all, :group => "category")
|
400
|
+
#
|
401
|
+
# Example for find with a lock. Imagine two concurrent transactions:
|
402
|
+
# each will read person.visits == 2, add 1 to it, and save, resulting
|
403
|
+
# in two saves of person.visits = 3. By locking the row, the second
|
404
|
+
# transaction has to wait until the first is finished; we get the
|
405
|
+
# expected person.visits == 4.
|
406
|
+
# Person.transaction do
|
407
|
+
# person = Person.find(1, :lock => true)
|
408
|
+
# person.visits += 1
|
409
|
+
# person.save!
|
410
|
+
# end
|
411
|
+
def find(*args)
|
412
|
+
options = extract_options_from_args!(args)
|
413
|
+
validate_find_options(options)
|
414
|
+
set_readonly_option!(options)
|
415
|
+
|
416
|
+
case args.first
|
417
|
+
when :first then find_initial(options)
|
418
|
+
when :all then find_every(options)
|
419
|
+
else find_from_ids(args, options)
|
420
|
+
end
|
421
|
+
end
|
422
|
+
|
423
|
+
# Works like find(:all), but requires a complete SQL string. Examples:
|
424
|
+
# Post.find_by_sql "SELECT p.*, c.author FROM posts p, comments c WHERE p.id = c.post_id"
|
425
|
+
# Post.find_by_sql ["SELECT * FROM posts WHERE author = ? AND created > ?", author_id, start_date]
|
426
|
+
def find_by_sql(sql)
|
427
|
+
connection.select_all(sanitize_sql(sql), "#{name} Load").collect! { |record| instantiate(record) }
|
428
|
+
end
|
429
|
+
|
430
|
+
# Returns true if the given +id+ represents the primary key of a record in the database, false otherwise.
|
431
|
+
# You can also pass a set of SQL conditions.
|
432
|
+
# Example:
|
433
|
+
# Person.exists?(5)
|
434
|
+
# Person.exists?('5')
|
435
|
+
# Person.exists?(:name => "David")
|
436
|
+
# Person.exists?(['name LIKE ?', "%#{query}%"])
|
437
|
+
def exists?(id_or_conditions)
|
438
|
+
!find(:first, :conditions => expand_id_conditions(id_or_conditions)).nil?
|
439
|
+
rescue ActiveRecord::ActiveRecordError
|
440
|
+
false
|
441
|
+
end
|
442
|
+
|
443
|
+
# Creates an object, instantly saves it as a record (if the validation permits it), and returns it. If the save
|
444
|
+
# fails under validations, the unsaved object is still returned.
|
445
|
+
def create(attributes = nil)
|
446
|
+
if attributes.is_a?(Array)
|
447
|
+
attributes.collect { |attr| create(attr) }
|
448
|
+
else
|
449
|
+
object = new(attributes)
|
450
|
+
scope(:create).each { |att,value| object.send("#{att}=", value) } if scoped?(:create)
|
451
|
+
object.save
|
452
|
+
object
|
453
|
+
end
|
454
|
+
end
|
455
|
+
|
456
|
+
# Finds the record from the passed +id+, instantly saves it with the passed +attributes+ (if the validation permits it),
|
457
|
+
# and returns it. If the save fails under validations, the unsaved object is still returned.
|
458
|
+
#
|
459
|
+
# The arguments may also be given as arrays in which case the update method is called for each pair of +id+ and
|
460
|
+
# +attributes+ and an array of objects is returned.
|
461
|
+
#
|
462
|
+
# Example of updating one record:
|
463
|
+
# Person.update(15, {:user_name => 'Samuel', :group => 'expert'})
|
464
|
+
#
|
465
|
+
# Example of updating multiple records:
|
466
|
+
# people = { 1 => { "first_name" => "David" }, 2 => { "first_name" => "Jeremy"} }
|
467
|
+
# Person.update(people.keys, people.values)
|
468
|
+
def update(id, attributes)
|
469
|
+
if id.is_a?(Array)
|
470
|
+
idx = -1
|
471
|
+
id.collect { |id| idx += 1; update(id, attributes[idx]) }
|
472
|
+
else
|
473
|
+
object = find(id)
|
474
|
+
object.update_attributes(attributes)
|
475
|
+
object
|
476
|
+
end
|
477
|
+
end
|
478
|
+
|
479
|
+
# Deletes the record with the given +id+ without instantiating an object first. If an array of ids is provided, all of them
|
480
|
+
# are deleted.
|
481
|
+
def delete(id)
|
482
|
+
delete_all([ "#{connection.quote_column_name(primary_key)} IN (?)", id ])
|
483
|
+
end
|
484
|
+
|
485
|
+
# Destroys the record with the given +id+ by instantiating the object and calling #destroy (all the callbacks are the triggered).
|
486
|
+
# If an array of ids is provided, all of them are destroyed.
|
487
|
+
def destroy(id)
|
488
|
+
id.is_a?(Array) ? id.each { |id| destroy(id) } : find(id).destroy
|
489
|
+
end
|
490
|
+
|
491
|
+
# Updates all records with the SET-part of an SQL update statement in +updates+ and returns an integer with the number of rows updated.
|
492
|
+
# A subset of the records can be selected by specifying +conditions+. Example:
|
493
|
+
# Billing.update_all "category = 'authorized', approved = 1", "author = 'David'"
|
494
|
+
def update_all(updates, conditions = nil)
|
495
|
+
sql = "UPDATE #{table_name} SET #{sanitize_sql(updates)} "
|
496
|
+
add_conditions!(sql, conditions, scope(:find))
|
497
|
+
connection.update(sql, "#{name} Update")
|
498
|
+
end
|
499
|
+
|
500
|
+
# Destroys the objects for all the records that match the +condition+ by instantiating each object and calling
|
501
|
+
# the destroy method. Example:
|
502
|
+
# Person.destroy_all "last_login < '2004-04-04'"
|
503
|
+
def destroy_all(conditions = nil)
|
504
|
+
find(:all, :conditions => conditions).each { |object| object.destroy }
|
505
|
+
end
|
506
|
+
|
507
|
+
# Deletes all the records that match the +condition+ without instantiating the objects first (and hence not
|
508
|
+
# calling the destroy method). Example:
|
509
|
+
# Post.delete_all "person_id = 5 AND (category = 'Something' OR category = 'Else')"
|
510
|
+
def delete_all(conditions = nil)
|
511
|
+
sql = "DELETE FROM #{table_name} "
|
512
|
+
add_conditions!(sql, conditions, scope(:find))
|
513
|
+
connection.delete(sql, "#{name} Delete all")
|
514
|
+
end
|
515
|
+
|
516
|
+
# Returns the result of an SQL statement that should only include a COUNT(*) in the SELECT part.
|
517
|
+
# Product.count_by_sql "SELECT COUNT(*) FROM sales s, customers c WHERE s.customer_id = c.id"
|
518
|
+
def count_by_sql(sql)
|
519
|
+
sql = sanitize_conditions(sql)
|
520
|
+
connection.select_value(sql, "#{name} Count").to_i
|
521
|
+
end
|
522
|
+
|
523
|
+
# Increments the specified counter by one. So <tt>DiscussionBoard.increment_counter("post_count",
|
524
|
+
# discussion_board_id)</tt> would increment the "post_count" counter on the board responding to discussion_board_id.
|
525
|
+
# This is used for caching aggregate values, so that they don't need to be computed every time. Especially important
|
526
|
+
# for looping over a collection where each element require a number of aggregate values. Like the DiscussionBoard
|
527
|
+
# that needs to list both the number of posts and comments.
|
528
|
+
def increment_counter(counter_name, id)
|
529
|
+
update_all "#{connection.quote_column_name(counter_name)} = #{connection.quote_column_name(counter_name)} + 1", "#{connection.quote_column_name(primary_key)} = #{quote_value(id)}"
|
530
|
+
end
|
531
|
+
|
532
|
+
# Works like increment_counter, but decrements instead.
|
533
|
+
def decrement_counter(counter_name, id)
|
534
|
+
update_all "#{connection.quote_column_name(counter_name)} = #{connection.quote_column_name(counter_name)} - 1", "#{connection.quote_column_name(primary_key)} = #{quote_value(id)}"
|
535
|
+
end
|
536
|
+
|
537
|
+
|
538
|
+
# Attributes named in this macro are protected from mass-assignment, such as <tt>new(attributes)</tt> and
|
539
|
+
# <tt>attributes=(attributes)</tt>. Their assignment will simply be ignored. Instead, you can use the direct writer
|
540
|
+
# methods to do assignment. This is meant to protect sensitive attributes from being overwritten by URL/form hackers. Example:
|
541
|
+
#
|
542
|
+
# class Customer < ActiveRecord::Base
|
543
|
+
# attr_protected :credit_rating
|
544
|
+
# end
|
545
|
+
#
|
546
|
+
# customer = Customer.new("name" => David, "credit_rating" => "Excellent")
|
547
|
+
# customer.credit_rating # => nil
|
548
|
+
# customer.attributes = { "description" => "Jolly fellow", "credit_rating" => "Superb" }
|
549
|
+
# customer.credit_rating # => nil
|
550
|
+
#
|
551
|
+
# customer.credit_rating = "Average"
|
552
|
+
# customer.credit_rating # => "Average"
|
553
|
+
def attr_protected(*attributes)
|
554
|
+
write_inheritable_array("attr_protected", attributes - (protected_attributes || []))
|
555
|
+
end
|
556
|
+
|
557
|
+
# Returns an array of all the attributes that have been protected from mass-assignment.
|
558
|
+
def protected_attributes # :nodoc:
|
559
|
+
read_inheritable_attribute("attr_protected")
|
560
|
+
end
|
561
|
+
|
562
|
+
# If this macro is used, only those attributes named in it will be accessible for mass-assignment, such as
|
563
|
+
# <tt>new(attributes)</tt> and <tt>attributes=(attributes)</tt>. This is the more conservative choice for mass-assignment
|
564
|
+
# protection. If you'd rather start from an all-open default and restrict attributes as needed, have a look at
|
565
|
+
# attr_protected.
|
566
|
+
def attr_accessible(*attributes)
|
567
|
+
write_inheritable_array("attr_accessible", attributes - (accessible_attributes || []))
|
568
|
+
end
|
569
|
+
|
570
|
+
# Returns an array of all the attributes that have been made accessible to mass-assignment.
|
571
|
+
def accessible_attributes # :nodoc:
|
572
|
+
read_inheritable_attribute("attr_accessible")
|
573
|
+
end
|
574
|
+
|
575
|
+
|
576
|
+
# Specifies that the attribute by the name of +attr_name+ should be serialized before saving to the database and unserialized
|
577
|
+
# after loading from the database. The serialization is done through YAML. If +class_name+ is specified, the serialized
|
578
|
+
# object must be of that class on retrieval or +SerializationTypeMismatch+ will be raised.
|
579
|
+
def serialize(attr_name, class_name = Object)
|
580
|
+
serialized_attributes[attr_name.to_s] = class_name
|
581
|
+
end
|
582
|
+
|
583
|
+
# Returns a hash of all the attributes that have been specified for serialization as keys and their class restriction as values.
|
584
|
+
def serialized_attributes
|
585
|
+
read_inheritable_attribute("attr_serialized") or write_inheritable_attribute("attr_serialized", {})
|
586
|
+
end
|
587
|
+
|
588
|
+
|
589
|
+
# Guesses the table name (in forced lower-case) based on the name of the class in the inheritance hierarchy descending
|
590
|
+
# directly from ActiveRecord. So if the hierarchy looks like: Reply < Message < ActiveRecord, then Message is used
|
591
|
+
# to guess the table name from even when called on Reply. The rules used to do the guess are handled by the Inflector class
|
592
|
+
# in Active Support, which knows almost all common English inflections (report a bug if your inflection isn't covered).
|
593
|
+
#
|
594
|
+
# Nested classes are given table names prefixed by the singular form of
|
595
|
+
# the parent's table name. Example:
|
596
|
+
# file class table_name
|
597
|
+
# invoice.rb Invoice invoices
|
598
|
+
# invoice/lineitem.rb Invoice::Lineitem invoice_lineitems
|
599
|
+
#
|
600
|
+
# Additionally, the class-level table_name_prefix is prepended and the
|
601
|
+
# table_name_suffix is appended. So if you have "myapp_" as a prefix,
|
602
|
+
# the table name guess for an Invoice class becomes "myapp_invoices".
|
603
|
+
# Invoice::Lineitem becomes "myapp_invoice_lineitems".
|
604
|
+
#
|
605
|
+
# You can also overwrite this class method to allow for unguessable
|
606
|
+
# links, such as a Mouse class with a link to a "mice" table. Example:
|
607
|
+
#
|
608
|
+
# class Mouse < ActiveRecord::Base
|
609
|
+
# set_table_name "mice"
|
610
|
+
# end
|
611
|
+
def table_name
|
612
|
+
reset_table_name
|
613
|
+
end
|
614
|
+
|
615
|
+
def reset_table_name #:nodoc:
|
616
|
+
base = base_class
|
617
|
+
|
618
|
+
name =
|
619
|
+
# STI subclasses always use their superclass' table.
|
620
|
+
unless self == base
|
621
|
+
base.table_name
|
622
|
+
else
|
623
|
+
# Nested classes are prefixed with singular parent table name.
|
624
|
+
if parent < ActiveRecord::Base && !parent.abstract_class?
|
625
|
+
contained = parent.table_name
|
626
|
+
contained = contained.singularize if parent.pluralize_table_names
|
627
|
+
contained << '_'
|
628
|
+
end
|
629
|
+
name = "#{table_name_prefix}#{contained}#{undecorated_table_name(base.name)}#{table_name_suffix}"
|
630
|
+
end
|
631
|
+
|
632
|
+
set_table_name(name)
|
633
|
+
name
|
634
|
+
end
|
635
|
+
|
636
|
+
# Defines the primary key field -- can be overridden in subclasses. Overwriting will negate any effect of the
|
637
|
+
# primary_key_prefix_type setting, though.
|
638
|
+
def primary_key
|
639
|
+
reset_primary_key
|
640
|
+
end
|
641
|
+
|
642
|
+
def reset_primary_key #:nodoc:
|
643
|
+
key = 'id'
|
644
|
+
case primary_key_prefix_type
|
645
|
+
when :table_name
|
646
|
+
key = Inflector.foreign_key(base_class.name, false)
|
647
|
+
when :table_name_with_underscore
|
648
|
+
key = Inflector.foreign_key(base_class.name)
|
649
|
+
end
|
650
|
+
set_primary_key(key)
|
651
|
+
key
|
652
|
+
end
|
653
|
+
|
654
|
+
# Defines the column name for use with single table inheritance
|
655
|
+
# -- can be set in subclasses like so: self.inheritance_column = "type_id"
|
656
|
+
def inheritance_column
|
657
|
+
@inheritance_column ||= "type".freeze
|
658
|
+
end
|
659
|
+
|
660
|
+
# Lazy-set the sequence name to the connection's default. This method
|
661
|
+
# is only ever called once since set_sequence_name overrides it.
|
662
|
+
def sequence_name #:nodoc:
|
663
|
+
reset_sequence_name
|
664
|
+
end
|
665
|
+
|
666
|
+
def reset_sequence_name #:nodoc:
|
667
|
+
default = connection.default_sequence_name(table_name, primary_key)
|
668
|
+
set_sequence_name(default)
|
669
|
+
default
|
670
|
+
end
|
671
|
+
|
672
|
+
# Sets the table name to use to the given value, or (if the value
|
673
|
+
# is nil or false) to the value returned by the given block.
|
674
|
+
#
|
675
|
+
# Example:
|
676
|
+
#
|
677
|
+
# class Project < ActiveRecord::Base
|
678
|
+
# set_table_name "project"
|
679
|
+
# end
|
680
|
+
def set_table_name(value = nil, &block)
|
681
|
+
define_attr_method :table_name, value, &block
|
682
|
+
end
|
683
|
+
alias :table_name= :set_table_name
|
684
|
+
|
685
|
+
# Sets the name of the primary key column to use to the given value,
|
686
|
+
# or (if the value is nil or false) to the value returned by the given
|
687
|
+
# block.
|
688
|
+
#
|
689
|
+
# Example:
|
690
|
+
#
|
691
|
+
# class Project < ActiveRecord::Base
|
692
|
+
# set_primary_key "sysid"
|
693
|
+
# end
|
694
|
+
def set_primary_key(value = nil, &block)
|
695
|
+
define_attr_method :primary_key, value, &block
|
696
|
+
end
|
697
|
+
alias :primary_key= :set_primary_key
|
698
|
+
|
699
|
+
# Sets the name of the inheritance column to use to the given value,
|
700
|
+
# or (if the value # is nil or false) to the value returned by the
|
701
|
+
# given block.
|
702
|
+
#
|
703
|
+
# Example:
|
704
|
+
#
|
705
|
+
# class Project < ActiveRecord::Base
|
706
|
+
# set_inheritance_column do
|
707
|
+
# original_inheritance_column + "_id"
|
708
|
+
# end
|
709
|
+
# end
|
710
|
+
def set_inheritance_column(value = nil, &block)
|
711
|
+
define_attr_method :inheritance_column, value, &block
|
712
|
+
end
|
713
|
+
alias :inheritance_column= :set_inheritance_column
|
714
|
+
|
715
|
+
# Sets the name of the sequence to use when generating ids to the given
|
716
|
+
# value, or (if the value is nil or false) to the value returned by the
|
717
|
+
# given block. This is required for Oracle and is useful for any
|
718
|
+
# database which relies on sequences for primary key generation.
|
719
|
+
#
|
720
|
+
# If a sequence name is not explicitly set when using Oracle or Firebird,
|
721
|
+
# it will default to the commonly used pattern of: #{table_name}_seq
|
722
|
+
#
|
723
|
+
# If a sequence name is not explicitly set when using PostgreSQL, it
|
724
|
+
# will discover the sequence corresponding to your primary key for you.
|
725
|
+
#
|
726
|
+
# Example:
|
727
|
+
#
|
728
|
+
# class Project < ActiveRecord::Base
|
729
|
+
# set_sequence_name "projectseq" # default would have been "project_seq"
|
730
|
+
# end
|
731
|
+
def set_sequence_name(value = nil, &block)
|
732
|
+
define_attr_method :sequence_name, value, &block
|
733
|
+
end
|
734
|
+
alias :sequence_name= :set_sequence_name
|
735
|
+
|
736
|
+
# Turns the +table_name+ back into a class name following the reverse rules of +table_name+.
|
737
|
+
def class_name(table_name = table_name) # :nodoc:
|
738
|
+
# remove any prefix and/or suffix from the table name
|
739
|
+
class_name = table_name[table_name_prefix.length..-(table_name_suffix.length + 1)].camelize
|
740
|
+
class_name = class_name.singularize if pluralize_table_names
|
741
|
+
class_name
|
742
|
+
end
|
743
|
+
|
744
|
+
# Indicates whether the table associated with this class exists
|
745
|
+
def table_exists?
|
746
|
+
if connection.respond_to?(:tables)
|
747
|
+
connection.tables.include? table_name
|
748
|
+
else
|
749
|
+
# if the connection adapter hasn't implemented tables, there are two crude tests that can be
|
750
|
+
# used - see if getting column info raises an error, or if the number of columns returned is zero
|
751
|
+
begin
|
752
|
+
reset_column_information
|
753
|
+
columns.size > 0
|
754
|
+
rescue ActiveRecord::StatementInvalid
|
755
|
+
false
|
756
|
+
end
|
757
|
+
end
|
758
|
+
end
|
759
|
+
|
760
|
+
# Returns an array of column objects for the table associated with this class.
|
761
|
+
def columns
|
762
|
+
unless @columns
|
763
|
+
@columns = connection.columns(table_name, "#{name} Columns")
|
764
|
+
@columns.each {|column| column.primary = column.name == primary_key}
|
765
|
+
end
|
766
|
+
@columns
|
767
|
+
end
|
768
|
+
|
769
|
+
# Returns a hash of column objects for the table associated with this class.
|
770
|
+
def columns_hash
|
771
|
+
@columns_hash ||= columns.inject({}) { |hash, column| hash[column.name] = column; hash }
|
772
|
+
end
|
773
|
+
|
774
|
+
# Returns an array of column names as strings.
|
775
|
+
def column_names
|
776
|
+
@column_names ||= columns.map { |column| column.name }
|
777
|
+
end
|
778
|
+
|
779
|
+
# Returns an array of column objects where the primary id, all columns ending in "_id" or "_count",
|
780
|
+
# and columns used for single table inheritance have been removed.
|
781
|
+
def content_columns
|
782
|
+
@content_columns ||= columns.reject { |c| c.primary || c.name =~ /(_id|_count)$/ || c.name == inheritance_column }
|
783
|
+
end
|
784
|
+
|
785
|
+
# Returns a hash of all the methods added to query each of the columns in the table with the name of the method as the key
|
786
|
+
# and true as the value. This makes it possible to do O(1) lookups in respond_to? to check if a given method for attribute
|
787
|
+
# is available.
|
788
|
+
def column_methods_hash #:nodoc:
|
789
|
+
@dynamic_methods_hash ||= column_names.inject(Hash.new(false)) do |methods, attr|
|
790
|
+
attr_name = attr.to_s
|
791
|
+
methods[attr.to_sym] = attr_name
|
792
|
+
methods["#{attr}=".to_sym] = attr_name
|
793
|
+
methods["#{attr}?".to_sym] = attr_name
|
794
|
+
methods["#{attr}_before_type_cast".to_sym] = attr_name
|
795
|
+
methods
|
796
|
+
end
|
797
|
+
end
|
798
|
+
|
799
|
+
# Contains the names of the generated reader methods.
|
800
|
+
def read_methods #:nodoc:
|
801
|
+
@read_methods ||= Set.new
|
802
|
+
end
|
803
|
+
|
804
|
+
# Resets all the cached information about columns, which will cause them to be reloaded on the next request.
|
805
|
+
def reset_column_information
|
806
|
+
read_methods.each { |name| undef_method(name) }
|
807
|
+
@column_names = @columns = @columns_hash = @content_columns = @dynamic_methods_hash = @read_methods = @inheritance_column = nil
|
808
|
+
end
|
809
|
+
|
810
|
+
def reset_column_information_and_inheritable_attributes_for_all_subclasses#:nodoc:
|
811
|
+
subclasses.each { |klass| klass.reset_inheritable_attributes; klass.reset_column_information }
|
812
|
+
end
|
813
|
+
|
814
|
+
# Transforms attribute key names into a more humane format, such as "First name" instead of "first_name". Example:
|
815
|
+
# Person.human_attribute_name("first_name") # => "First name"
|
816
|
+
# Deprecated in favor of just calling "first_name".humanize
|
817
|
+
def human_attribute_name(attribute_key_name) #:nodoc:
|
818
|
+
attribute_key_name.humanize
|
819
|
+
end
|
820
|
+
|
821
|
+
def descends_from_active_record? # :nodoc:
|
822
|
+
superclass == Base || !columns_hash.include?(inheritance_column)
|
823
|
+
end
|
824
|
+
|
825
|
+
|
826
|
+
def quote_value(value, column = nil) #:nodoc:
|
827
|
+
connection.quote(value,column)
|
828
|
+
end
|
829
|
+
|
830
|
+
def quote(value, column = nil) #:nodoc:
|
831
|
+
connection.quote(value, column)
|
832
|
+
end
|
833
|
+
deprecate :quote => :quote_value
|
834
|
+
|
835
|
+
# Used to sanitize objects before they're used in an SELECT SQL-statement. Delegates to <tt>connection.quote</tt>.
|
836
|
+
def sanitize(object) #:nodoc:
|
837
|
+
connection.quote(object)
|
838
|
+
end
|
839
|
+
|
840
|
+
# Log and benchmark multiple statements in a single block. Example:
|
841
|
+
#
|
842
|
+
# Project.benchmark("Creating project") do
|
843
|
+
# project = Project.create("name" => "stuff")
|
844
|
+
# project.create_manager("name" => "David")
|
845
|
+
# project.milestones << Milestone.find(:all)
|
846
|
+
# end
|
847
|
+
#
|
848
|
+
# The benchmark is only recorded if the current level of the logger matches the <tt>log_level</tt>, which makes it
|
849
|
+
# easy to include benchmarking statements in production software that will remain inexpensive because the benchmark
|
850
|
+
# will only be conducted if the log level is low enough.
|
851
|
+
#
|
852
|
+
# The logging of the multiple statements is turned off unless <tt>use_silence</tt> is set to false.
|
853
|
+
def benchmark(title, log_level = Logger::DEBUG, use_silence = true)
|
854
|
+
if logger && logger.level == log_level
|
855
|
+
result = nil
|
856
|
+
seconds = Benchmark.realtime { result = use_silence ? silence { yield } : yield }
|
857
|
+
logger.add(log_level, "#{title} (#{'%.5f' % seconds})")
|
858
|
+
result
|
859
|
+
else
|
860
|
+
yield
|
861
|
+
end
|
862
|
+
end
|
863
|
+
|
864
|
+
# Silences the logger for the duration of the block.
|
865
|
+
def silence
|
866
|
+
old_logger_level, logger.level = logger.level, Logger::ERROR if logger
|
867
|
+
yield
|
868
|
+
ensure
|
869
|
+
logger.level = old_logger_level if logger
|
870
|
+
end
|
871
|
+
|
872
|
+
# Scope parameters to method calls within the block. Takes a hash of method_name => parameters hash.
|
873
|
+
# method_name may be :find or :create. :find parameters may include the <tt>:conditions</tt>, <tt>:joins</tt>,
|
874
|
+
# <tt>:include</tt>, <tt>:offset</tt>, <tt>:limit</tt>, and <tt>:readonly</tt> options. :create parameters are an attributes hash.
|
875
|
+
#
|
876
|
+
# Article.with_scope(:find => { :conditions => "blog_id = 1" }, :create => { :blog_id => 1 }) do
|
877
|
+
# Article.find(1) # => SELECT * from articles WHERE blog_id = 1 AND id = 1
|
878
|
+
# a = Article.create(1)
|
879
|
+
# a.blog_id # => 1
|
880
|
+
# end
|
881
|
+
#
|
882
|
+
# In nested scopings, all previous parameters are overwritten by inner rule
|
883
|
+
# except :conditions in :find, that are merged as hash.
|
884
|
+
#
|
885
|
+
# Article.with_scope(:find => { :conditions => "blog_id = 1", :limit => 1 }, :create => { :blog_id => 1 }) do
|
886
|
+
# Article.with_scope(:find => { :limit => 10})
|
887
|
+
# Article.find(:all) # => SELECT * from articles WHERE blog_id = 1 LIMIT 10
|
888
|
+
# end
|
889
|
+
# Article.with_scope(:find => { :conditions => "author_id = 3" })
|
890
|
+
# Article.find(:all) # => SELECT * from articles WHERE blog_id = 1 AND author_id = 3 LIMIT 1
|
891
|
+
# end
|
892
|
+
# end
|
893
|
+
#
|
894
|
+
# You can ignore any previous scopings by using <tt>with_exclusive_scope</tt> method.
|
895
|
+
#
|
896
|
+
# Article.with_scope(:find => { :conditions => "blog_id = 1", :limit => 1 }) do
|
897
|
+
# Article.with_exclusive_scope(:find => { :limit => 10 })
|
898
|
+
# Article.find(:all) # => SELECT * from articles LIMIT 10
|
899
|
+
# end
|
900
|
+
# end
|
901
|
+
def with_scope(method_scoping = {}, action = :merge, &block)
|
902
|
+
method_scoping = method_scoping.method_scoping if method_scoping.respond_to?(:method_scoping)
|
903
|
+
|
904
|
+
# Dup first and second level of hash (method and params).
|
905
|
+
method_scoping = method_scoping.inject({}) do |hash, (method, params)|
|
906
|
+
hash[method] = (params == true) ? params : params.dup
|
907
|
+
hash
|
908
|
+
end
|
909
|
+
|
910
|
+
method_scoping.assert_valid_keys([ :find, :create ])
|
911
|
+
|
912
|
+
if f = method_scoping[:find]
|
913
|
+
f.assert_valid_keys([ :conditions, :joins, :select, :include, :from, :offset, :limit, :order, :readonly, :lock ])
|
914
|
+
f[:readonly] = true if !f[:joins].blank? && !f.has_key?(:readonly)
|
915
|
+
end
|
916
|
+
|
917
|
+
# Merge scopings
|
918
|
+
if action == :merge && current_scoped_methods
|
919
|
+
method_scoping = current_scoped_methods.inject(method_scoping) do |hash, (method, params)|
|
920
|
+
case hash[method]
|
921
|
+
when Hash
|
922
|
+
if method == :find
|
923
|
+
(hash[method].keys + params.keys).uniq.each do |key|
|
924
|
+
merge = hash[method][key] && params[key] # merge if both scopes have the same key
|
925
|
+
if key == :conditions && merge
|
926
|
+
hash[method][key] = [params[key], hash[method][key]].collect{ |sql| "( %s )" % sanitize_sql(sql) }.join(" AND ")
|
927
|
+
elsif key == :include && merge
|
928
|
+
hash[method][key] = merge_includes(hash[method][key], params[key]).uniq
|
929
|
+
else
|
930
|
+
hash[method][key] = hash[method][key] || params[key]
|
931
|
+
end
|
932
|
+
end
|
933
|
+
else
|
934
|
+
hash[method] = params.merge(hash[method])
|
935
|
+
end
|
936
|
+
else
|
937
|
+
hash[method] = params
|
938
|
+
end
|
939
|
+
hash
|
940
|
+
end
|
941
|
+
end
|
942
|
+
|
943
|
+
self.scoped_methods << method_scoping
|
944
|
+
|
945
|
+
begin
|
946
|
+
yield
|
947
|
+
ensure
|
948
|
+
self.scoped_methods.pop
|
949
|
+
end
|
950
|
+
end
|
951
|
+
|
952
|
+
# Works like with_scope, but discards any nested properties.
|
953
|
+
def with_exclusive_scope(method_scoping = {}, &block)
|
954
|
+
with_scope(method_scoping, :overwrite, &block)
|
955
|
+
end
|
956
|
+
|
957
|
+
# Overwrite the default class equality method to provide support for association proxies.
|
958
|
+
def ===(object)
|
959
|
+
object.is_a?(self)
|
960
|
+
end
|
961
|
+
|
962
|
+
# Deprecated
|
963
|
+
def threaded_connections #:nodoc:
|
964
|
+
allow_concurrency
|
965
|
+
end
|
966
|
+
|
967
|
+
# Deprecated
|
968
|
+
def threaded_connections=(value) #:nodoc:
|
969
|
+
self.allow_concurrency = value
|
970
|
+
end
|
971
|
+
|
972
|
+
# Returns the base AR subclass that this class descends from. If A
|
973
|
+
# extends AR::Base, A.base_class will return A. If B descends from A
|
974
|
+
# through some arbitrarily deep hierarchy, B.base_class will return A.
|
975
|
+
def base_class
|
976
|
+
class_of_active_record_descendant(self)
|
977
|
+
end
|
978
|
+
|
979
|
+
# Set this to true if this is an abstract class (see #abstract_class?).
|
980
|
+
attr_accessor :abstract_class
|
981
|
+
|
982
|
+
# Returns whether this class is a base AR class. If A is a base class and
|
983
|
+
# B descends from A, then B.base_class will return B.
|
984
|
+
def abstract_class?
|
985
|
+
abstract_class == true
|
986
|
+
end
|
987
|
+
|
988
|
+
private
|
989
|
+
def find_initial(options)
|
990
|
+
options.update(:limit => 1) unless options[:include]
|
991
|
+
find_every(options).first
|
992
|
+
end
|
993
|
+
|
994
|
+
def find_every(options)
|
995
|
+
records = scoped?(:find, :include) || options[:include] ?
|
996
|
+
find_with_associations(options) :
|
997
|
+
find_by_sql(construct_finder_sql(options))
|
998
|
+
|
999
|
+
records.each { |record| record.readonly! } if options[:readonly]
|
1000
|
+
|
1001
|
+
records
|
1002
|
+
end
|
1003
|
+
|
1004
|
+
def find_from_ids(ids, options)
|
1005
|
+
expects_array = ids.first.kind_of?(Array)
|
1006
|
+
return ids.first if expects_array && ids.first.empty?
|
1007
|
+
|
1008
|
+
ids = ids.flatten.compact.uniq
|
1009
|
+
|
1010
|
+
case ids.size
|
1011
|
+
when 0
|
1012
|
+
raise RecordNotFound, "Couldn't find #{name} without an ID"
|
1013
|
+
when 1
|
1014
|
+
result = find_one(ids.first, options)
|
1015
|
+
expects_array ? [ result ] : result
|
1016
|
+
else
|
1017
|
+
find_some(ids, options)
|
1018
|
+
end
|
1019
|
+
end
|
1020
|
+
|
1021
|
+
def find_one(id, options)
|
1022
|
+
conditions = " AND (#{sanitize_sql(options[:conditions])})" if options[:conditions]
|
1023
|
+
options.update :conditions => "#{table_name}.#{connection.quote_column_name(primary_key)} = #{quote_value(id,columns_hash[primary_key])}#{conditions}"
|
1024
|
+
|
1025
|
+
# Use find_every(options).first since the primary key condition
|
1026
|
+
# already ensures we have a single record. Using find_initial adds
|
1027
|
+
# a superfluous :limit => 1.
|
1028
|
+
if result = find_every(options).first
|
1029
|
+
result
|
1030
|
+
else
|
1031
|
+
raise RecordNotFound, "Couldn't find #{name} with ID=#{id}#{conditions}"
|
1032
|
+
end
|
1033
|
+
end
|
1034
|
+
|
1035
|
+
def find_some(ids, options)
|
1036
|
+
conditions = " AND (#{sanitize_sql(options[:conditions])})" if options[:conditions]
|
1037
|
+
ids_list = ids.map { |id| quote_value(id,columns_hash[primary_key]) }.join(',')
|
1038
|
+
options.update :conditions => "#{table_name}.#{connection.quote_column_name(primary_key)} IN (#{ids_list})#{conditions}"
|
1039
|
+
|
1040
|
+
result = find_every(options)
|
1041
|
+
|
1042
|
+
if result.size == ids.size
|
1043
|
+
result
|
1044
|
+
else
|
1045
|
+
raise RecordNotFound, "Couldn't find all #{name.pluralize} with IDs (#{ids_list})#{conditions}"
|
1046
|
+
end
|
1047
|
+
end
|
1048
|
+
|
1049
|
+
# Finder methods must instantiate through this method to work with the
|
1050
|
+
# single-table inheritance model that makes it possible to create
|
1051
|
+
# objects of different types from the same table.
|
1052
|
+
def instantiate(record)
|
1053
|
+
object =
|
1054
|
+
if subclass_name = record[inheritance_column]
|
1055
|
+
if subclass_name.empty?
|
1056
|
+
# No type given.
|
1057
|
+
allocate
|
1058
|
+
else
|
1059
|
+
# Ignore type if no column is present since it was probably
|
1060
|
+
# pulled in from a sloppy join.
|
1061
|
+
unless columns_hash.include?(inheritance_column)
|
1062
|
+
allocate
|
1063
|
+
|
1064
|
+
else
|
1065
|
+
begin
|
1066
|
+
compute_type(subclass_name).allocate
|
1067
|
+
rescue NameError
|
1068
|
+
raise SubclassNotFound,
|
1069
|
+
"The single-table inheritance mechanism failed to locate the subclass: '#{record[inheritance_column]}'. " +
|
1070
|
+
"This error is raised because the column '#{inheritance_column}' is reserved for storing the class in case of inheritance. " +
|
1071
|
+
"Please rename this column if you didn't intend it to be used for storing the inheritance class " +
|
1072
|
+
"or overwrite #{self.to_s}.inheritance_column to use another column for that information."
|
1073
|
+
end
|
1074
|
+
end
|
1075
|
+
end
|
1076
|
+
else
|
1077
|
+
allocate
|
1078
|
+
end
|
1079
|
+
|
1080
|
+
object.instance_variable_set("@attributes", record)
|
1081
|
+
object
|
1082
|
+
end
|
1083
|
+
|
1084
|
+
# Nest the type name in the same module as this class.
|
1085
|
+
# Bar is "MyApp::Business::Bar" relative to MyApp::Business::Foo
|
1086
|
+
def type_name_with_module(type_name)
|
1087
|
+
(/^::/ =~ type_name) ? type_name : "#{parent.name}::#{type_name}"
|
1088
|
+
end
|
1089
|
+
|
1090
|
+
def construct_finder_sql(options)
|
1091
|
+
scope = scope(:find)
|
1092
|
+
sql = "SELECT #{(scope && scope[:select]) || options[:select] || '*'} "
|
1093
|
+
sql << "FROM #{(scope && scope[:from]) || options[:from] || table_name} "
|
1094
|
+
|
1095
|
+
add_joins!(sql, options, scope)
|
1096
|
+
add_conditions!(sql, options[:conditions], scope)
|
1097
|
+
|
1098
|
+
sql << " GROUP BY #{options[:group]} " if options[:group]
|
1099
|
+
|
1100
|
+
add_order!(sql, options[:order], scope)
|
1101
|
+
add_limit!(sql, options, scope)
|
1102
|
+
add_lock!(sql, options, scope)
|
1103
|
+
|
1104
|
+
sql
|
1105
|
+
end
|
1106
|
+
|
1107
|
+
# Merges includes so that the result is a valid +include+
|
1108
|
+
def merge_includes(first, second)
|
1109
|
+
(safe_to_array(first) + safe_to_array(second)).uniq
|
1110
|
+
end
|
1111
|
+
|
1112
|
+
# Object#to_a is deprecated, though it does have the desired behavior
|
1113
|
+
def safe_to_array(o)
|
1114
|
+
case o
|
1115
|
+
when NilClass
|
1116
|
+
[]
|
1117
|
+
when Array
|
1118
|
+
o
|
1119
|
+
else
|
1120
|
+
[o]
|
1121
|
+
end
|
1122
|
+
end
|
1123
|
+
|
1124
|
+
def add_order!(sql, order, scope = :auto)
|
1125
|
+
scope = scope(:find) if :auto == scope
|
1126
|
+
scoped_order = scope[:order] if scope
|
1127
|
+
if order
|
1128
|
+
sql << " ORDER BY #{order}"
|
1129
|
+
sql << ", #{scoped_order}" if scoped_order
|
1130
|
+
else
|
1131
|
+
sql << " ORDER BY #{scoped_order}" if scoped_order
|
1132
|
+
end
|
1133
|
+
end
|
1134
|
+
|
1135
|
+
# The optional scope argument is for the current :find scope.
|
1136
|
+
def add_limit!(sql, options, scope = :auto)
|
1137
|
+
scope = scope(:find) if :auto == scope
|
1138
|
+
options = options.reverse_merge(:limit => scope[:limit], :offset => scope[:offset]) if scope
|
1139
|
+
connection.add_limit_offset!(sql, options)
|
1140
|
+
end
|
1141
|
+
|
1142
|
+
# The optional scope argument is for the current :find scope.
|
1143
|
+
# The :lock option has precedence over a scoped :lock.
|
1144
|
+
def add_lock!(sql, options, scope = :auto)
|
1145
|
+
scope = scope(:find) if :auto == scope
|
1146
|
+
options = options.reverse_merge(:lock => scope[:lock]) if scope
|
1147
|
+
connection.add_lock!(sql, options)
|
1148
|
+
end
|
1149
|
+
|
1150
|
+
# The optional scope argument is for the current :find scope.
|
1151
|
+
def add_joins!(sql, options, scope = :auto)
|
1152
|
+
scope = scope(:find) if :auto == scope
|
1153
|
+
join = (scope && scope[:joins]) || options[:joins]
|
1154
|
+
sql << " #{join} " if join
|
1155
|
+
end
|
1156
|
+
|
1157
|
+
# Adds a sanitized version of +conditions+ to the +sql+ string. Note that the passed-in +sql+ string is changed.
|
1158
|
+
# The optional scope argument is for the current :find scope.
|
1159
|
+
def add_conditions!(sql, conditions, scope = :auto)
|
1160
|
+
scope = scope(:find) if :auto == scope
|
1161
|
+
segments = []
|
1162
|
+
segments << sanitize_sql(scope[:conditions]) if scope && scope[:conditions]
|
1163
|
+
segments << sanitize_sql(conditions) unless conditions.nil?
|
1164
|
+
segments << type_condition unless descends_from_active_record?
|
1165
|
+
segments.compact!
|
1166
|
+
sql << "WHERE (#{segments.join(") AND (")}) " unless segments.empty?
|
1167
|
+
end
|
1168
|
+
|
1169
|
+
def type_condition
|
1170
|
+
quoted_inheritance_column = connection.quote_column_name(inheritance_column)
|
1171
|
+
type_condition = subclasses.inject("#{table_name}.#{quoted_inheritance_column} = '#{name.demodulize}' ") do |condition, subclass|
|
1172
|
+
condition << "OR #{table_name}.#{quoted_inheritance_column} = '#{subclass.name.demodulize}' "
|
1173
|
+
end
|
1174
|
+
|
1175
|
+
" (#{type_condition}) "
|
1176
|
+
end
|
1177
|
+
|
1178
|
+
# Guesses the table name, but does not decorate it with prefix and suffix information.
|
1179
|
+
def undecorated_table_name(class_name = base_class.name)
|
1180
|
+
table_name = Inflector.underscore(Inflector.demodulize(class_name))
|
1181
|
+
table_name = Inflector.pluralize(table_name) if pluralize_table_names
|
1182
|
+
table_name
|
1183
|
+
end
|
1184
|
+
|
1185
|
+
# Enables dynamic finders like find_by_user_name(user_name) and find_by_user_name_and_password(user_name, password) that are turned into
|
1186
|
+
# find(:first, :conditions => ["user_name = ?", user_name]) and find(:first, :conditions => ["user_name = ? AND password = ?", user_name, password])
|
1187
|
+
# respectively. Also works for find(:all), but using find_all_by_amount(50) that are turned into find(:all, :conditions => ["amount = ?", 50]).
|
1188
|
+
#
|
1189
|
+
# It's even possible to use all the additional parameters to find. For example, the full interface for find_all_by_amount
|
1190
|
+
# is actually find_all_by_amount(amount, options).
|
1191
|
+
def method_missing(method_id, *arguments)
|
1192
|
+
if match = /^find_(all_by|by)_([_a-zA-Z]\w*)$/.match(method_id.to_s)
|
1193
|
+
finder, deprecated_finder = determine_finder(match), determine_deprecated_finder(match)
|
1194
|
+
|
1195
|
+
attribute_names = extract_attribute_names_from_match(match)
|
1196
|
+
super unless all_attributes_exists?(attribute_names)
|
1197
|
+
|
1198
|
+
attributes = construct_attributes_from_arguments(attribute_names, arguments)
|
1199
|
+
|
1200
|
+
case extra_options = arguments[attribute_names.size]
|
1201
|
+
when nil
|
1202
|
+
options = { :conditions => attributes }
|
1203
|
+
set_readonly_option!(options)
|
1204
|
+
ActiveSupport::Deprecation.silence { send(finder, options) }
|
1205
|
+
|
1206
|
+
when Hash
|
1207
|
+
finder_options = extra_options.merge(:conditions => attributes)
|
1208
|
+
validate_find_options(finder_options)
|
1209
|
+
set_readonly_option!(finder_options)
|
1210
|
+
|
1211
|
+
if extra_options[:conditions]
|
1212
|
+
with_scope(:find => { :conditions => extra_options[:conditions] }) do
|
1213
|
+
ActiveSupport::Deprecation.silence { send(finder, finder_options) }
|
1214
|
+
end
|
1215
|
+
else
|
1216
|
+
ActiveSupport::Deprecation.silence { send(finder, finder_options) }
|
1217
|
+
end
|
1218
|
+
|
1219
|
+
else
|
1220
|
+
ActiveSupport::Deprecation.silence do
|
1221
|
+
send(deprecated_finder, sanitize_sql(attributes), *arguments[attribute_names.length..-1])
|
1222
|
+
end
|
1223
|
+
end
|
1224
|
+
elsif match = /^find_or_(initialize|create)_by_([_a-zA-Z]\w*)$/.match(method_id.to_s)
|
1225
|
+
instantiator = determine_instantiator(match)
|
1226
|
+
attribute_names = extract_attribute_names_from_match(match)
|
1227
|
+
super unless all_attributes_exists?(attribute_names)
|
1228
|
+
|
1229
|
+
attributes = construct_attributes_from_arguments(attribute_names, arguments)
|
1230
|
+
options = { :conditions => attributes }
|
1231
|
+
set_readonly_option!(options)
|
1232
|
+
|
1233
|
+
find_initial(options) || send(instantiator, attributes)
|
1234
|
+
else
|
1235
|
+
super
|
1236
|
+
end
|
1237
|
+
end
|
1238
|
+
|
1239
|
+
def determine_finder(match)
|
1240
|
+
match.captures.first == 'all_by' ? :find_every : :find_initial
|
1241
|
+
end
|
1242
|
+
|
1243
|
+
def determine_deprecated_finder(match)
|
1244
|
+
match.captures.first == 'all_by' ? :find_all : :find_first
|
1245
|
+
end
|
1246
|
+
|
1247
|
+
def determine_instantiator(match)
|
1248
|
+
match.captures.first == 'initialize' ? :new : :create
|
1249
|
+
end
|
1250
|
+
|
1251
|
+
def extract_attribute_names_from_match(match)
|
1252
|
+
match.captures.last.split('_and_')
|
1253
|
+
end
|
1254
|
+
|
1255
|
+
def construct_attributes_from_arguments(attribute_names, arguments)
|
1256
|
+
attributes = {}
|
1257
|
+
attribute_names.each_with_index { |name, idx| attributes[name] = arguments[idx] }
|
1258
|
+
attributes
|
1259
|
+
end
|
1260
|
+
|
1261
|
+
def all_attributes_exists?(attribute_names)
|
1262
|
+
attribute_names.all? { |name| column_methods_hash.include?(name.to_sym) }
|
1263
|
+
end
|
1264
|
+
|
1265
|
+
def attribute_condition(argument)
|
1266
|
+
case argument
|
1267
|
+
when nil then "IS ?"
|
1268
|
+
when Array then "IN (?)"
|
1269
|
+
when Range then "BETWEEN ? AND ?"
|
1270
|
+
else "= ?"
|
1271
|
+
end
|
1272
|
+
end
|
1273
|
+
|
1274
|
+
# Interpret Array and Hash as conditions and anything else as an id.
|
1275
|
+
def expand_id_conditions(id_or_conditions)
|
1276
|
+
case id_or_conditions
|
1277
|
+
when Array, Hash then id_or_conditions
|
1278
|
+
else sanitize_sql(primary_key => id_or_conditions)
|
1279
|
+
end
|
1280
|
+
end
|
1281
|
+
|
1282
|
+
|
1283
|
+
# Defines an "attribute" method (like #inheritance_column or
|
1284
|
+
# #table_name). A new (class) method will be created with the
|
1285
|
+
# given name. If a value is specified, the new method will
|
1286
|
+
# return that value (as a string). Otherwise, the given block
|
1287
|
+
# will be used to compute the value of the method.
|
1288
|
+
#
|
1289
|
+
# The original method will be aliased, with the new name being
|
1290
|
+
# prefixed with "original_". This allows the new method to
|
1291
|
+
# access the original value.
|
1292
|
+
#
|
1293
|
+
# Example:
|
1294
|
+
#
|
1295
|
+
# class A < ActiveRecord::Base
|
1296
|
+
# define_attr_method :primary_key, "sysid"
|
1297
|
+
# define_attr_method( :inheritance_column ) do
|
1298
|
+
# original_inheritance_column + "_id"
|
1299
|
+
# end
|
1300
|
+
# end
|
1301
|
+
def define_attr_method(name, value=nil, &block)
|
1302
|
+
sing = class << self; self; end
|
1303
|
+
sing.send :alias_method, "original_#{name}", name
|
1304
|
+
if block_given?
|
1305
|
+
sing.send :define_method, name, &block
|
1306
|
+
else
|
1307
|
+
# use eval instead of a block to work around a memory leak in dev
|
1308
|
+
# mode in fcgi
|
1309
|
+
sing.class_eval "def #{name}; #{value.to_s.inspect}; end"
|
1310
|
+
end
|
1311
|
+
end
|
1312
|
+
|
1313
|
+
protected
|
1314
|
+
def subclasses #:nodoc:
|
1315
|
+
@@subclasses[self] ||= []
|
1316
|
+
@@subclasses[self] + extra = @@subclasses[self].inject([]) {|list, subclass| list + subclass.subclasses }
|
1317
|
+
end
|
1318
|
+
|
1319
|
+
# Test whether the given method and optional key are scoped.
|
1320
|
+
def scoped?(method, key = nil) #:nodoc:
|
1321
|
+
if current_scoped_methods && (scope = current_scoped_methods[method])
|
1322
|
+
!key || scope.has_key?(key)
|
1323
|
+
end
|
1324
|
+
end
|
1325
|
+
|
1326
|
+
# Retrieve the scope for the given method and optional key.
|
1327
|
+
def scope(method, key = nil) #:nodoc:
|
1328
|
+
if current_scoped_methods && (scope = current_scoped_methods[method])
|
1329
|
+
key ? scope[key] : scope
|
1330
|
+
end
|
1331
|
+
end
|
1332
|
+
|
1333
|
+
def thread_safe_scoped_methods #:nodoc:
|
1334
|
+
scoped_methods = (Thread.current[:scoped_methods] ||= {})
|
1335
|
+
scoped_methods[self] ||= []
|
1336
|
+
end
|
1337
|
+
|
1338
|
+
def single_threaded_scoped_methods #:nodoc:
|
1339
|
+
@scoped_methods ||= []
|
1340
|
+
end
|
1341
|
+
|
1342
|
+
# pick up the correct scoped_methods version from @@allow_concurrency
|
1343
|
+
if @@allow_concurrency
|
1344
|
+
alias_method :scoped_methods, :thread_safe_scoped_methods
|
1345
|
+
else
|
1346
|
+
alias_method :scoped_methods, :single_threaded_scoped_methods
|
1347
|
+
end
|
1348
|
+
|
1349
|
+
def current_scoped_methods #:nodoc:
|
1350
|
+
scoped_methods.last
|
1351
|
+
end
|
1352
|
+
|
1353
|
+
# Returns the class type of the record using the current module as a prefix. So descendents of
|
1354
|
+
# MyApp::Business::Account would appear as MyApp::Business::AccountSubclass.
|
1355
|
+
def compute_type(type_name)
|
1356
|
+
modularized_name = type_name_with_module(type_name)
|
1357
|
+
begin
|
1358
|
+
class_eval(modularized_name, __FILE__, __LINE__)
|
1359
|
+
rescue NameError
|
1360
|
+
class_eval(type_name, __FILE__, __LINE__)
|
1361
|
+
end
|
1362
|
+
end
|
1363
|
+
|
1364
|
+
# Returns the class descending directly from ActiveRecord in the inheritance hierarchy.
|
1365
|
+
def class_of_active_record_descendant(klass)
|
1366
|
+
if klass.superclass == Base || klass.superclass.abstract_class?
|
1367
|
+
klass
|
1368
|
+
elsif klass.superclass.nil?
|
1369
|
+
raise ActiveRecordError, "#{name} doesn't belong in a hierarchy descending from ActiveRecord"
|
1370
|
+
else
|
1371
|
+
class_of_active_record_descendant(klass.superclass)
|
1372
|
+
end
|
1373
|
+
end
|
1374
|
+
|
1375
|
+
# Returns the name of the class descending directly from ActiveRecord in the inheritance hierarchy.
|
1376
|
+
def class_name_of_active_record_descendant(klass) #:nodoc:
|
1377
|
+
klass.base_class.name
|
1378
|
+
end
|
1379
|
+
|
1380
|
+
# Accepts an array, hash, or string of sql conditions and sanitizes
|
1381
|
+
# them into a valid SQL fragment.
|
1382
|
+
# ["name='%s' and group_id='%s'", "foo'bar", 4] returns "name='foo''bar' and group_id='4'"
|
1383
|
+
# { :name => "foo'bar", :group_id => 4 } returns "name='foo''bar' and group_id='4'"
|
1384
|
+
# "name='foo''bar' and group_id='4'" returns "name='foo''bar' and group_id='4'"
|
1385
|
+
def sanitize_sql(condition)
|
1386
|
+
case condition
|
1387
|
+
when Array; sanitize_sql_array(condition)
|
1388
|
+
when Hash; sanitize_sql_hash(condition)
|
1389
|
+
else condition
|
1390
|
+
end
|
1391
|
+
end
|
1392
|
+
|
1393
|
+
# Sanitizes a hash of attribute/value pairs into SQL conditions.
|
1394
|
+
# { :name => "foo'bar", :group_id => 4 }
|
1395
|
+
# # => "name='foo''bar' and group_id= 4"
|
1396
|
+
# { :status => nil, :group_id => [1,2,3] }
|
1397
|
+
# # => "status IS NULL and group_id IN (1,2,3)"
|
1398
|
+
# { :age => 13..18 }
|
1399
|
+
# # => "age BETWEEN 13 AND 18"
|
1400
|
+
def sanitize_sql_hash(attrs)
|
1401
|
+
conditions = attrs.map do |attr, value|
|
1402
|
+
"#{table_name}.#{connection.quote_column_name(attr)} #{attribute_condition(value)}"
|
1403
|
+
end.join(' AND ')
|
1404
|
+
|
1405
|
+
replace_bind_variables(conditions, expand_range_bind_variables(attrs.values))
|
1406
|
+
end
|
1407
|
+
|
1408
|
+
# Accepts an array of conditions. The array has each value
|
1409
|
+
# sanitized and interpolated into the sql statement.
|
1410
|
+
# ["name='%s' and group_id='%s'", "foo'bar", 4] returns "name='foo''bar' and group_id='4'"
|
1411
|
+
def sanitize_sql_array(ary)
|
1412
|
+
statement, *values = ary
|
1413
|
+
if values.first.is_a?(Hash) and statement =~ /:\w+/
|
1414
|
+
replace_named_bind_variables(statement, values.first)
|
1415
|
+
elsif statement.include?('?')
|
1416
|
+
replace_bind_variables(statement, values)
|
1417
|
+
else
|
1418
|
+
statement % values.collect { |value| connection.quote_string(value.to_s) }
|
1419
|
+
end
|
1420
|
+
end
|
1421
|
+
|
1422
|
+
alias_method :sanitize_conditions, :sanitize_sql
|
1423
|
+
|
1424
|
+
def replace_bind_variables(statement, values) #:nodoc:
|
1425
|
+
raise_if_bind_arity_mismatch(statement, statement.count('?'), values.size)
|
1426
|
+
bound = values.dup
|
1427
|
+
statement.gsub('?') { quote_bound_value(bound.shift) }
|
1428
|
+
end
|
1429
|
+
|
1430
|
+
def replace_named_bind_variables(statement, bind_vars) #:nodoc:
|
1431
|
+
statement.gsub(/:(\w+)/) do
|
1432
|
+
match = $1.to_sym
|
1433
|
+
if bind_vars.include?(match)
|
1434
|
+
quote_bound_value(bind_vars[match])
|
1435
|
+
else
|
1436
|
+
raise PreparedStatementInvalid, "missing value for :#{match} in #{statement}"
|
1437
|
+
end
|
1438
|
+
end
|
1439
|
+
end
|
1440
|
+
|
1441
|
+
def expand_range_bind_variables(bind_vars) #:nodoc:
|
1442
|
+
bind_vars.each_with_index do |var, index|
|
1443
|
+
bind_vars[index, 1] = [var.first, var.last] if var.is_a?(Range)
|
1444
|
+
end
|
1445
|
+
bind_vars
|
1446
|
+
end
|
1447
|
+
|
1448
|
+
def quote_bound_value(value) #:nodoc:
|
1449
|
+
if value.respond_to?(:map) && !value.is_a?(String)
|
1450
|
+
if value.respond_to?(:empty?) && value.empty?
|
1451
|
+
connection.quote(nil)
|
1452
|
+
else
|
1453
|
+
value.map { |v| connection.quote(v) }.join(',')
|
1454
|
+
end
|
1455
|
+
else
|
1456
|
+
connection.quote(value)
|
1457
|
+
end
|
1458
|
+
end
|
1459
|
+
|
1460
|
+
def raise_if_bind_arity_mismatch(statement, expected, provided) #:nodoc:
|
1461
|
+
unless expected == provided
|
1462
|
+
raise PreparedStatementInvalid, "wrong number of bind variables (#{provided} for #{expected}) in: #{statement}"
|
1463
|
+
end
|
1464
|
+
end
|
1465
|
+
|
1466
|
+
def extract_options_from_args!(args) #:nodoc:
|
1467
|
+
args.last.is_a?(Hash) ? args.pop : {}
|
1468
|
+
end
|
1469
|
+
|
1470
|
+
VALID_FIND_OPTIONS = [ :conditions, :include, :joins, :limit, :offset,
|
1471
|
+
:order, :select, :readonly, :group, :from, :lock ]
|
1472
|
+
|
1473
|
+
def validate_find_options(options) #:nodoc:
|
1474
|
+
options.assert_valid_keys(VALID_FIND_OPTIONS)
|
1475
|
+
end
|
1476
|
+
|
1477
|
+
def set_readonly_option!(options) #:nodoc:
|
1478
|
+
# Inherit :readonly from finder scope if set. Otherwise,
|
1479
|
+
# if :joins is not blank then :readonly defaults to true.
|
1480
|
+
unless options.has_key?(:readonly)
|
1481
|
+
if scoped?(:find, :readonly)
|
1482
|
+
options[:readonly] = scope(:find, :readonly)
|
1483
|
+
elsif !options[:joins].blank? && !options[:select]
|
1484
|
+
options[:readonly] = true
|
1485
|
+
end
|
1486
|
+
end
|
1487
|
+
end
|
1488
|
+
|
1489
|
+
def encode_quoted_value(value) #:nodoc:
|
1490
|
+
quoted_value = connection.quote(value)
|
1491
|
+
quoted_value = "'#{quoted_value[1..-2].gsub(/\'/, "\\\\'")}'" if quoted_value.include?("\\\'") # (for ruby mode) "
|
1492
|
+
quoted_value
|
1493
|
+
end
|
1494
|
+
end
|
1495
|
+
|
1496
|
+
public
|
1497
|
+
# New objects can be instantiated as either empty (pass no construction parameter) or pre-set with
|
1498
|
+
# attributes but not yet saved (pass a hash with key names matching the associated table column names).
|
1499
|
+
# In both instances, valid attribute keys are determined by the column names of the associated table --
|
1500
|
+
# hence you can't have attributes that aren't part of the table columns.
|
1501
|
+
def initialize(attributes = nil)
|
1502
|
+
@attributes = attributes_from_column_definition
|
1503
|
+
@new_record = true
|
1504
|
+
ensure_proper_type
|
1505
|
+
self.attributes = attributes unless attributes.nil?
|
1506
|
+
yield self if block_given?
|
1507
|
+
end
|
1508
|
+
|
1509
|
+
# A model instance's primary key is always available as model.id
|
1510
|
+
# whether you name it the default 'id' or set it to something else.
|
1511
|
+
def id
|
1512
|
+
attr_name = self.class.primary_key
|
1513
|
+
column = column_for_attribute(attr_name)
|
1514
|
+
define_read_method(:id, attr_name, column) if self.class.generate_read_methods
|
1515
|
+
read_attribute(attr_name)
|
1516
|
+
end
|
1517
|
+
|
1518
|
+
# Enables Active Record objects to be used as URL parameters in Action Pack automatically.
|
1519
|
+
def to_param
|
1520
|
+
# We can't use alias_method here, because method 'id' optimizes itself on the fly.
|
1521
|
+
(id = self.id) ? id.to_s : nil # Be sure to stringify the id for routes
|
1522
|
+
end
|
1523
|
+
|
1524
|
+
def id_before_type_cast #:nodoc:
|
1525
|
+
read_attribute_before_type_cast(self.class.primary_key)
|
1526
|
+
end
|
1527
|
+
|
1528
|
+
def quoted_id #:nodoc:
|
1529
|
+
quote_value(id, column_for_attribute(self.class.primary_key))
|
1530
|
+
end
|
1531
|
+
|
1532
|
+
# Sets the primary ID.
|
1533
|
+
def id=(value)
|
1534
|
+
write_attribute(self.class.primary_key, value)
|
1535
|
+
end
|
1536
|
+
|
1537
|
+
# Returns true if this object hasn't been saved yet -- that is, a record for the object doesn't exist yet.
|
1538
|
+
def new_record?
|
1539
|
+
@new_record
|
1540
|
+
end
|
1541
|
+
|
1542
|
+
# * No record exists: Creates a new record with values matching those of the object attributes.
|
1543
|
+
# * A record does exist: Updates the record with values matching those of the object attributes.
|
1544
|
+
def save
|
1545
|
+
create_or_update
|
1546
|
+
end
|
1547
|
+
|
1548
|
+
# Attempts to save the record, but instead of just returning false if it couldn't happen, it raises a
|
1549
|
+
# RecordNotSaved exception
|
1550
|
+
def save!
|
1551
|
+
create_or_update || raise(RecordNotSaved)
|
1552
|
+
end
|
1553
|
+
|
1554
|
+
# Deletes the record in the database and freezes this instance to reflect that no changes should
|
1555
|
+
# be made (since they can't be persisted).
|
1556
|
+
def destroy
|
1557
|
+
unless new_record?
|
1558
|
+
connection.delete <<-end_sql, "#{self.class.name} Destroy"
|
1559
|
+
DELETE FROM #{self.class.table_name}
|
1560
|
+
WHERE #{connection.quote_column_name(self.class.primary_key)} = #{quoted_id}
|
1561
|
+
end_sql
|
1562
|
+
end
|
1563
|
+
|
1564
|
+
freeze
|
1565
|
+
end
|
1566
|
+
|
1567
|
+
# Returns a clone of the record that hasn't been assigned an id yet and
|
1568
|
+
# is treated as a new record. Note that this is a "shallow" clone:
|
1569
|
+
# it copies the object's attributes only, not its associations.
|
1570
|
+
# The extent of a "deep" clone is application-specific and is therefore
|
1571
|
+
# left to the application to implement according to its need.
|
1572
|
+
def clone
|
1573
|
+
attrs = self.attributes_before_type_cast
|
1574
|
+
attrs.delete(self.class.primary_key)
|
1575
|
+
self.class.new do |record|
|
1576
|
+
record.send :instance_variable_set, '@attributes', attrs
|
1577
|
+
end
|
1578
|
+
end
|
1579
|
+
|
1580
|
+
# Updates a single attribute and saves the record. This is especially useful for boolean flags on existing records.
|
1581
|
+
# Note: This method is overwritten by the Validation module that'll make sure that updates made with this method
|
1582
|
+
# doesn't get subjected to validation checks. Hence, attributes can be updated even if the full object isn't valid.
|
1583
|
+
def update_attribute(name, value)
|
1584
|
+
send(name.to_s + '=', value)
|
1585
|
+
save
|
1586
|
+
end
|
1587
|
+
|
1588
|
+
# Updates all the attributes from the passed-in Hash and saves the record. If the object is invalid, the saving will
|
1589
|
+
# fail and false will be returned.
|
1590
|
+
def update_attributes(attributes)
|
1591
|
+
self.attributes = attributes
|
1592
|
+
save
|
1593
|
+
end
|
1594
|
+
|
1595
|
+
# Updates an object just like Base.update_attributes but calls save! instead of save so an exception is raised if the record is invalid.
|
1596
|
+
def update_attributes!(attributes)
|
1597
|
+
self.attributes = attributes
|
1598
|
+
save!
|
1599
|
+
end
|
1600
|
+
|
1601
|
+
# Initializes the +attribute+ to zero if nil and adds one. Only makes sense for number-based attributes. Returns self.
|
1602
|
+
def increment(attribute)
|
1603
|
+
self[attribute] ||= 0
|
1604
|
+
self[attribute] += 1
|
1605
|
+
self
|
1606
|
+
end
|
1607
|
+
|
1608
|
+
# Increments the +attribute+ and saves the record.
|
1609
|
+
def increment!(attribute)
|
1610
|
+
increment(attribute).update_attribute(attribute, self[attribute])
|
1611
|
+
end
|
1612
|
+
|
1613
|
+
# Initializes the +attribute+ to zero if nil and subtracts one. Only makes sense for number-based attributes. Returns self.
|
1614
|
+
def decrement(attribute)
|
1615
|
+
self[attribute] ||= 0
|
1616
|
+
self[attribute] -= 1
|
1617
|
+
self
|
1618
|
+
end
|
1619
|
+
|
1620
|
+
# Decrements the +attribute+ and saves the record.
|
1621
|
+
def decrement!(attribute)
|
1622
|
+
decrement(attribute).update_attribute(attribute, self[attribute])
|
1623
|
+
end
|
1624
|
+
|
1625
|
+
# Turns an +attribute+ that's currently true into false and vice versa. Returns self.
|
1626
|
+
def toggle(attribute)
|
1627
|
+
self[attribute] = !send("#{attribute}?")
|
1628
|
+
self
|
1629
|
+
end
|
1630
|
+
|
1631
|
+
# Toggles the +attribute+ and saves the record.
|
1632
|
+
def toggle!(attribute)
|
1633
|
+
toggle(attribute).update_attribute(attribute, self[attribute])
|
1634
|
+
end
|
1635
|
+
|
1636
|
+
# Reloads the attributes of this object from the database.
|
1637
|
+
# The optional options argument is passed to find when reloading so you
|
1638
|
+
# may do e.g. record.reload(:lock => true) to reload the same record with
|
1639
|
+
# an exclusive row lock.
|
1640
|
+
def reload(options = nil)
|
1641
|
+
clear_aggregation_cache
|
1642
|
+
clear_association_cache
|
1643
|
+
@attributes.update(self.class.find(self.id, options).instance_variable_get('@attributes'))
|
1644
|
+
self
|
1645
|
+
end
|
1646
|
+
|
1647
|
+
# Returns the value of the attribute identified by <tt>attr_name</tt> after it has been typecast (for example,
|
1648
|
+
# "2004-12-12" in a data column is cast to a date object, like Date.new(2004, 12, 12)).
|
1649
|
+
# (Alias for the protected read_attribute method).
|
1650
|
+
def [](attr_name)
|
1651
|
+
read_attribute(attr_name)
|
1652
|
+
end
|
1653
|
+
|
1654
|
+
# Updates the attribute identified by <tt>attr_name</tt> with the specified +value+.
|
1655
|
+
# (Alias for the protected write_attribute method).
|
1656
|
+
def []=(attr_name, value)
|
1657
|
+
write_attribute(attr_name, value)
|
1658
|
+
end
|
1659
|
+
|
1660
|
+
# Allows you to set all the attributes at once by passing in a hash with keys
|
1661
|
+
# matching the attribute names (which again matches the column names). Sensitive attributes can be protected
|
1662
|
+
# from this form of mass-assignment by using the +attr_protected+ macro. Or you can alternatively
|
1663
|
+
# specify which attributes *can* be accessed in with the +attr_accessible+ macro. Then all the
|
1664
|
+
# attributes not included in that won't be allowed to be mass-assigned.
|
1665
|
+
def attributes=(new_attributes)
|
1666
|
+
return if new_attributes.nil?
|
1667
|
+
attributes = new_attributes.dup
|
1668
|
+
attributes.stringify_keys!
|
1669
|
+
|
1670
|
+
multi_parameter_attributes = []
|
1671
|
+
remove_attributes_protected_from_mass_assignment(attributes).each do |k, v|
|
1672
|
+
k.include?("(") ? multi_parameter_attributes << [ k, v ] : send(k + "=", v)
|
1673
|
+
end
|
1674
|
+
|
1675
|
+
assign_multiparameter_attributes(multi_parameter_attributes)
|
1676
|
+
end
|
1677
|
+
|
1678
|
+
|
1679
|
+
# Returns a hash of all the attributes with their names as keys and clones of their objects as values.
|
1680
|
+
def attributes(options = nil)
|
1681
|
+
attributes = clone_attributes :read_attribute
|
1682
|
+
|
1683
|
+
if options.nil?
|
1684
|
+
attributes
|
1685
|
+
else
|
1686
|
+
if except = options[:except]
|
1687
|
+
except = Array(except).collect { |attribute| attribute.to_s }
|
1688
|
+
except.each { |attribute_name| attributes.delete(attribute_name) }
|
1689
|
+
attributes
|
1690
|
+
elsif only = options[:only]
|
1691
|
+
only = Array(only).collect { |attribute| attribute.to_s }
|
1692
|
+
attributes.delete_if { |key, value| !only.include?(key) }
|
1693
|
+
attributes
|
1694
|
+
else
|
1695
|
+
raise ArgumentError, "Options does not specify :except or :only (#{options.keys.inspect})"
|
1696
|
+
end
|
1697
|
+
end
|
1698
|
+
end
|
1699
|
+
|
1700
|
+
# Returns a hash of cloned attributes before typecasting and deserialization.
|
1701
|
+
def attributes_before_type_cast
|
1702
|
+
clone_attributes :read_attribute_before_type_cast
|
1703
|
+
end
|
1704
|
+
|
1705
|
+
# Returns true if the specified +attribute+ has been set by the user or by a database load and is neither
|
1706
|
+
# nil nor empty? (the latter only applies to objects that respond to empty?, most notably Strings).
|
1707
|
+
def attribute_present?(attribute)
|
1708
|
+
value = read_attribute(attribute)
|
1709
|
+
!value.blank? or value == 0
|
1710
|
+
end
|
1711
|
+
|
1712
|
+
# Returns true if the given attribute is in the attributes hash
|
1713
|
+
def has_attribute?(attr_name)
|
1714
|
+
@attributes.has_key?(attr_name.to_s)
|
1715
|
+
end
|
1716
|
+
|
1717
|
+
# Returns an array of names for the attributes available on this object sorted alphabetically.
|
1718
|
+
def attribute_names
|
1719
|
+
@attributes.keys.sort
|
1720
|
+
end
|
1721
|
+
|
1722
|
+
# Returns the column object for the named attribute.
|
1723
|
+
def column_for_attribute(name)
|
1724
|
+
self.class.columns_hash[name.to_s]
|
1725
|
+
end
|
1726
|
+
|
1727
|
+
# Returns true if the +comparison_object+ is the same object, or is of the same type and has the same id.
|
1728
|
+
def ==(comparison_object)
|
1729
|
+
comparison_object.equal?(self) ||
|
1730
|
+
(comparison_object.instance_of?(self.class) &&
|
1731
|
+
comparison_object.id == id &&
|
1732
|
+
!comparison_object.new_record?)
|
1733
|
+
end
|
1734
|
+
|
1735
|
+
# Delegates to ==
|
1736
|
+
def eql?(comparison_object)
|
1737
|
+
self == (comparison_object)
|
1738
|
+
end
|
1739
|
+
|
1740
|
+
# Delegates to id in order to allow two records of the same type and id to work with something like:
|
1741
|
+
# [ Person.find(1), Person.find(2), Person.find(3) ] & [ Person.find(1), Person.find(4) ] # => [ Person.find(1) ]
|
1742
|
+
def hash
|
1743
|
+
id.hash
|
1744
|
+
end
|
1745
|
+
|
1746
|
+
# For checking respond_to? without searching the attributes (which is faster).
|
1747
|
+
alias_method :respond_to_without_attributes?, :respond_to?
|
1748
|
+
|
1749
|
+
# A Person object with a name attribute can ask person.respond_to?("name"), person.respond_to?("name="), and
|
1750
|
+
# person.respond_to?("name?") which will all return true.
|
1751
|
+
def respond_to?(method, include_priv = false)
|
1752
|
+
if @attributes.nil?
|
1753
|
+
return super
|
1754
|
+
elsif attr_name = self.class.column_methods_hash[method.to_sym]
|
1755
|
+
return true if @attributes.include?(attr_name) || attr_name == self.class.primary_key
|
1756
|
+
return false if self.class.read_methods.include?(attr_name)
|
1757
|
+
elsif @attributes.include?(method_name = method.to_s)
|
1758
|
+
return true
|
1759
|
+
elsif md = self.class.match_attribute_method?(method.to_s)
|
1760
|
+
return true if @attributes.include?(md.pre_match)
|
1761
|
+
end
|
1762
|
+
# super must be called at the end of the method, because the inherited respond_to?
|
1763
|
+
# would return true for generated readers, even if the attribute wasn't present
|
1764
|
+
super
|
1765
|
+
end
|
1766
|
+
|
1767
|
+
# Just freeze the attributes hash, such that associations are still accessible even on destroyed records.
|
1768
|
+
def freeze
|
1769
|
+
@attributes.freeze; self
|
1770
|
+
end
|
1771
|
+
|
1772
|
+
def frozen?
|
1773
|
+
@attributes.frozen?
|
1774
|
+
end
|
1775
|
+
|
1776
|
+
# Records loaded through joins with piggy-back attributes will be marked as read only as they cannot be saved and return true to this query.
|
1777
|
+
def readonly?
|
1778
|
+
@readonly == true
|
1779
|
+
end
|
1780
|
+
|
1781
|
+
def readonly! #:nodoc:
|
1782
|
+
@readonly = true
|
1783
|
+
end
|
1784
|
+
|
1785
|
+
|
1786
|
+
private
|
1787
|
+
def create_or_update
|
1788
|
+
raise ReadOnlyRecord if readonly?
|
1789
|
+
result = new_record? ? create : update
|
1790
|
+
result != false
|
1791
|
+
end
|
1792
|
+
|
1793
|
+
# Updates the associated record with values matching those of the instance attributes.
|
1794
|
+
# Returns the number of affected rows.
|
1795
|
+
def update
|
1796
|
+
connection.update(
|
1797
|
+
"UPDATE #{self.class.table_name} " +
|
1798
|
+
"SET #{quoted_comma_pair_list(connection, attributes_with_quotes(false))} " +
|
1799
|
+
"WHERE #{connection.quote_column_name(self.class.primary_key)} = #{quote_value(id)}",
|
1800
|
+
"#{self.class.name} Update"
|
1801
|
+
)
|
1802
|
+
end
|
1803
|
+
|
1804
|
+
# Creates a record with values matching those of the instance attributes
|
1805
|
+
# and returns its id.
|
1806
|
+
def create
|
1807
|
+
if self.id.nil? && connection.prefetch_primary_key?(self.class.table_name)
|
1808
|
+
self.id = connection.next_sequence_value(self.class.sequence_name)
|
1809
|
+
end
|
1810
|
+
|
1811
|
+
self.id = connection.insert(
|
1812
|
+
"INSERT INTO #{self.class.table_name} " +
|
1813
|
+
"(#{quoted_column_names.join(', ')}) " +
|
1814
|
+
"VALUES(#{attributes_with_quotes.values.join(', ')})",
|
1815
|
+
"#{self.class.name} Create",
|
1816
|
+
self.class.primary_key, self.id, self.class.sequence_name
|
1817
|
+
)
|
1818
|
+
|
1819
|
+
@new_record = false
|
1820
|
+
id
|
1821
|
+
end
|
1822
|
+
|
1823
|
+
# Sets the attribute used for single table inheritance to this class name if this is not the ActiveRecord descendent.
|
1824
|
+
# Considering the hierarchy Reply < Message < ActiveRecord, this makes it possible to do Reply.new without having to
|
1825
|
+
# set Reply[Reply.inheritance_column] = "Reply" yourself. No such attribute would be set for objects of the
|
1826
|
+
# Message class in that example.
|
1827
|
+
def ensure_proper_type
|
1828
|
+
unless self.class.descends_from_active_record?
|
1829
|
+
write_attribute(self.class.inheritance_column, Inflector.demodulize(self.class.name))
|
1830
|
+
end
|
1831
|
+
end
|
1832
|
+
|
1833
|
+
|
1834
|
+
# Allows access to the object attributes, which are held in the @attributes hash, as were
|
1835
|
+
# they first-class methods. So a Person class with a name attribute can use Person#name and
|
1836
|
+
# Person#name= and never directly use the attributes hash -- except for multiple assigns with
|
1837
|
+
# ActiveRecord#attributes=. A Milestone class can also ask Milestone#completed? to test that
|
1838
|
+
# the completed attribute is not nil or 0.
|
1839
|
+
#
|
1840
|
+
# It's also possible to instantiate related objects, so a Client class belonging to the clients
|
1841
|
+
# table with a master_id foreign key can instantiate master through Client#master.
|
1842
|
+
def method_missing(method_id, *args, &block)
|
1843
|
+
method_name = method_id.to_s
|
1844
|
+
if @attributes.include?(method_name) or
|
1845
|
+
(md = /\?$/.match(method_name) and
|
1846
|
+
@attributes.include?(query_method_name = md.pre_match) and
|
1847
|
+
method_name = query_method_name)
|
1848
|
+
define_read_methods if self.class.read_methods.empty? && self.class.generate_read_methods
|
1849
|
+
md ? query_attribute(method_name) : read_attribute(method_name)
|
1850
|
+
elsif self.class.primary_key.to_s == method_name
|
1851
|
+
id
|
1852
|
+
elsif md = self.class.match_attribute_method?(method_name)
|
1853
|
+
attribute_name, method_type = md.pre_match, md.to_s
|
1854
|
+
if @attributes.include?(attribute_name)
|
1855
|
+
__send__("attribute#{method_type}", attribute_name, *args, &block)
|
1856
|
+
else
|
1857
|
+
super
|
1858
|
+
end
|
1859
|
+
else
|
1860
|
+
super
|
1861
|
+
end
|
1862
|
+
end
|
1863
|
+
|
1864
|
+
# Returns the value of the attribute identified by <tt>attr_name</tt> after it has been typecast (for example,
|
1865
|
+
# "2004-12-12" in a data column is cast to a date object, like Date.new(2004, 12, 12)).
|
1866
|
+
def read_attribute(attr_name)
|
1867
|
+
attr_name = attr_name.to_s
|
1868
|
+
if !(value = @attributes[attr_name]).nil?
|
1869
|
+
if column = column_for_attribute(attr_name)
|
1870
|
+
if unserializable_attribute?(attr_name, column)
|
1871
|
+
unserialize_attribute(attr_name)
|
1872
|
+
else
|
1873
|
+
column.type_cast(value)
|
1874
|
+
end
|
1875
|
+
else
|
1876
|
+
value
|
1877
|
+
end
|
1878
|
+
else
|
1879
|
+
nil
|
1880
|
+
end
|
1881
|
+
end
|
1882
|
+
|
1883
|
+
def read_attribute_before_type_cast(attr_name)
|
1884
|
+
@attributes[attr_name]
|
1885
|
+
end
|
1886
|
+
|
1887
|
+
# Called on first read access to any given column and generates reader
|
1888
|
+
# methods for all columns in the columns_hash if
|
1889
|
+
# ActiveRecord::Base.generate_read_methods is set to true.
|
1890
|
+
def define_read_methods
|
1891
|
+
self.class.columns_hash.each do |name, column|
|
1892
|
+
unless respond_to_without_attributes?(name)
|
1893
|
+
if self.class.serialized_attributes[name]
|
1894
|
+
define_read_method_for_serialized_attribute(name)
|
1895
|
+
else
|
1896
|
+
define_read_method(name.to_sym, name, column)
|
1897
|
+
end
|
1898
|
+
end
|
1899
|
+
|
1900
|
+
unless respond_to_without_attributes?("#{name}?")
|
1901
|
+
define_question_method(name)
|
1902
|
+
end
|
1903
|
+
end
|
1904
|
+
end
|
1905
|
+
|
1906
|
+
# Define an attribute reader method. Cope with nil column.
|
1907
|
+
def define_read_method(symbol, attr_name, column)
|
1908
|
+
cast_code = column.type_cast_code('v') if column
|
1909
|
+
access_code = cast_code ? "(v=@attributes['#{attr_name}']) && #{cast_code}" : "@attributes['#{attr_name}']"
|
1910
|
+
|
1911
|
+
unless attr_name.to_s == self.class.primary_key.to_s
|
1912
|
+
access_code = access_code.insert(0, "raise NoMethodError, 'missing attribute: #{attr_name}', caller unless @attributes.has_key?('#{attr_name}'); ")
|
1913
|
+
self.class.read_methods << attr_name
|
1914
|
+
end
|
1915
|
+
|
1916
|
+
evaluate_read_method attr_name, "def #{symbol}; #{access_code}; end"
|
1917
|
+
end
|
1918
|
+
|
1919
|
+
# Define read method for serialized attribute.
|
1920
|
+
def define_read_method_for_serialized_attribute(attr_name)
|
1921
|
+
unless attr_name.to_s == self.class.primary_key.to_s
|
1922
|
+
self.class.read_methods << attr_name
|
1923
|
+
end
|
1924
|
+
|
1925
|
+
evaluate_read_method attr_name, "def #{attr_name}; unserialize_attribute('#{attr_name}'); end"
|
1926
|
+
end
|
1927
|
+
|
1928
|
+
# Define an attribute ? method.
|
1929
|
+
def define_question_method(attr_name)
|
1930
|
+
unless attr_name.to_s == self.class.primary_key.to_s
|
1931
|
+
self.class.read_methods << "#{attr_name}?"
|
1932
|
+
end
|
1933
|
+
|
1934
|
+
evaluate_read_method attr_name, "def #{attr_name}?; query_attribute('#{attr_name}'); end"
|
1935
|
+
end
|
1936
|
+
|
1937
|
+
# Evaluate the definition for an attribute reader or ? method
|
1938
|
+
def evaluate_read_method(attr_name, method_definition)
|
1939
|
+
begin
|
1940
|
+
self.class.class_eval(method_definition)
|
1941
|
+
rescue SyntaxError => err
|
1942
|
+
self.class.read_methods.delete(attr_name)
|
1943
|
+
if logger
|
1944
|
+
logger.warn "Exception occurred during reader method compilation."
|
1945
|
+
logger.warn "Maybe #{attr_name} is not a valid Ruby identifier?"
|
1946
|
+
logger.warn "#{err.message}"
|
1947
|
+
end
|
1948
|
+
end
|
1949
|
+
end
|
1950
|
+
|
1951
|
+
# Returns true if the attribute is of a text column and marked for serialization.
|
1952
|
+
def unserializable_attribute?(attr_name, column)
|
1953
|
+
column.text? && self.class.serialized_attributes[attr_name]
|
1954
|
+
end
|
1955
|
+
|
1956
|
+
# Returns the unserialized object of the attribute.
|
1957
|
+
def unserialize_attribute(attr_name)
|
1958
|
+
unserialized_object = object_from_yaml(@attributes[attr_name])
|
1959
|
+
|
1960
|
+
if unserialized_object.is_a?(self.class.serialized_attributes[attr_name])
|
1961
|
+
@attributes[attr_name] = unserialized_object
|
1962
|
+
else
|
1963
|
+
raise SerializationTypeMismatch,
|
1964
|
+
"#{attr_name} was supposed to be a #{self.class.serialized_attributes[attr_name]}, but was a #{unserialized_object.class.to_s}"
|
1965
|
+
end
|
1966
|
+
end
|
1967
|
+
|
1968
|
+
# Updates the attribute identified by <tt>attr_name</tt> with the specified +value+. Empty strings for fixnum and float
|
1969
|
+
# columns are turned into nil.
|
1970
|
+
def write_attribute(attr_name, value)
|
1971
|
+
attr_name = attr_name.to_s
|
1972
|
+
if (column = column_for_attribute(attr_name)) && column.number?
|
1973
|
+
@attributes[attr_name] = convert_number_column_value(value)
|
1974
|
+
else
|
1975
|
+
@attributes[attr_name] = value
|
1976
|
+
end
|
1977
|
+
end
|
1978
|
+
|
1979
|
+
def convert_number_column_value(value)
|
1980
|
+
case value
|
1981
|
+
when FalseClass: 0
|
1982
|
+
when TrueClass: 1
|
1983
|
+
when '': nil
|
1984
|
+
else value
|
1985
|
+
end
|
1986
|
+
end
|
1987
|
+
|
1988
|
+
def query_attribute(attr_name)
|
1989
|
+
attribute = @attributes[attr_name]
|
1990
|
+
if attribute.kind_of?(Fixnum) && attribute == 0
|
1991
|
+
false
|
1992
|
+
elsif attribute.kind_of?(String) && attribute == "0"
|
1993
|
+
false
|
1994
|
+
elsif attribute.kind_of?(String) && attribute.empty?
|
1995
|
+
false
|
1996
|
+
elsif attribute.nil?
|
1997
|
+
false
|
1998
|
+
elsif attribute == false
|
1999
|
+
false
|
2000
|
+
elsif attribute == "f"
|
2001
|
+
false
|
2002
|
+
elsif attribute == "false"
|
2003
|
+
false
|
2004
|
+
else
|
2005
|
+
true
|
2006
|
+
end
|
2007
|
+
end
|
2008
|
+
|
2009
|
+
def remove_attributes_protected_from_mass_assignment(attributes)
|
2010
|
+
if self.class.accessible_attributes.nil? && self.class.protected_attributes.nil?
|
2011
|
+
attributes.reject { |key, value| attributes_protected_by_default.include?(key.gsub(/\(.+/, "")) }
|
2012
|
+
elsif self.class.protected_attributes.nil?
|
2013
|
+
attributes.reject { |key, value| !self.class.accessible_attributes.include?(key.gsub(/\(.+/, "").intern) || attributes_protected_by_default.include?(key.gsub(/\(.+/, "")) }
|
2014
|
+
elsif self.class.accessible_attributes.nil?
|
2015
|
+
attributes.reject { |key, value| self.class.protected_attributes.include?(key.gsub(/\(.+/,"").intern) || attributes_protected_by_default.include?(key.gsub(/\(.+/, "")) }
|
2016
|
+
end
|
2017
|
+
end
|
2018
|
+
|
2019
|
+
# The primary key and inheritance column can never be set by mass-assignment for security reasons.
|
2020
|
+
def attributes_protected_by_default
|
2021
|
+
default = [ self.class.primary_key, self.class.inheritance_column ]
|
2022
|
+
default << 'id' unless self.class.primary_key.eql? 'id'
|
2023
|
+
default
|
2024
|
+
end
|
2025
|
+
|
2026
|
+
# Returns copy of the attributes hash where all the values have been safely quoted for use in
|
2027
|
+
# an SQL statement.
|
2028
|
+
def attributes_with_quotes(include_primary_key = true)
|
2029
|
+
attributes.inject({}) do |quoted, (name, value)|
|
2030
|
+
if column = column_for_attribute(name)
|
2031
|
+
quoted[name] = quote_value(value, column) unless !include_primary_key && column.primary
|
2032
|
+
end
|
2033
|
+
quoted
|
2034
|
+
end
|
2035
|
+
end
|
2036
|
+
|
2037
|
+
# Quote strings appropriately for SQL statements.
|
2038
|
+
def quote_value(value, column = nil)
|
2039
|
+
self.class.connection.quote(value, column)
|
2040
|
+
end
|
2041
|
+
|
2042
|
+
# Deprecated, use quote_value
|
2043
|
+
def quote(value, column = nil)
|
2044
|
+
self.class.connection.quote(value, column)
|
2045
|
+
end
|
2046
|
+
deprecate :quote => :quote_value
|
2047
|
+
|
2048
|
+
|
2049
|
+
# Interpolate custom sql string in instance context.
|
2050
|
+
# Optional record argument is meant for custom insert_sql.
|
2051
|
+
def interpolate_sql(sql, record = nil)
|
2052
|
+
instance_eval("%@#{sql.gsub('@', '\@')}@")
|
2053
|
+
end
|
2054
|
+
|
2055
|
+
# Initializes the attributes array with keys matching the columns from the linked table and
|
2056
|
+
# the values matching the corresponding default value of that column, so
|
2057
|
+
# that a new instance, or one populated from a passed-in Hash, still has all the attributes
|
2058
|
+
# that instances loaded from the database would.
|
2059
|
+
def attributes_from_column_definition
|
2060
|
+
self.class.columns.inject({}) do |attributes, column|
|
2061
|
+
attributes[column.name] = column.default unless column.name == self.class.primary_key
|
2062
|
+
attributes
|
2063
|
+
end
|
2064
|
+
end
|
2065
|
+
|
2066
|
+
# Instantiates objects for all attribute classes that needs more than one constructor parameter. This is done
|
2067
|
+
# by calling new on the column type or aggregation type (through composed_of) object with these parameters.
|
2068
|
+
# So having the pairs written_on(1) = "2004", written_on(2) = "6", written_on(3) = "24", will instantiate
|
2069
|
+
# written_on (a date type) with Date.new("2004", "6", "24"). You can also specify a typecast character in the
|
2070
|
+
# parentheses to have the parameters typecasted before they're used in the constructor. Use i for Fixnum, f for Float,
|
2071
|
+
# s for String, and a for Array. If all the values for a given attribute is empty, the attribute will be set to nil.
|
2072
|
+
def assign_multiparameter_attributes(pairs)
|
2073
|
+
execute_callstack_for_multiparameter_attributes(
|
2074
|
+
extract_callstack_for_multiparameter_attributes(pairs)
|
2075
|
+
)
|
2076
|
+
end
|
2077
|
+
|
2078
|
+
# Includes an ugly hack for Time.local instead of Time.new because the latter is reserved by Time itself.
|
2079
|
+
def execute_callstack_for_multiparameter_attributes(callstack)
|
2080
|
+
errors = []
|
2081
|
+
callstack.each do |name, values|
|
2082
|
+
klass = (self.class.reflect_on_aggregation(name.to_sym) || column_for_attribute(name)).klass
|
2083
|
+
if values.empty?
|
2084
|
+
send(name + "=", nil)
|
2085
|
+
else
|
2086
|
+
begin
|
2087
|
+
send(name + "=", Time == klass ? (@@default_timezone == :utc ? klass.utc(*values) : klass.local(*values)) : klass.new(*values))
|
2088
|
+
rescue => ex
|
2089
|
+
errors << AttributeAssignmentError.new("error on assignment #{values.inspect} to #{name}", ex, name)
|
2090
|
+
end
|
2091
|
+
end
|
2092
|
+
end
|
2093
|
+
unless errors.empty?
|
2094
|
+
raise MultiparameterAssignmentErrors.new(errors), "#{errors.size} error(s) on assignment of multiparameter attributes"
|
2095
|
+
end
|
2096
|
+
end
|
2097
|
+
|
2098
|
+
def extract_callstack_for_multiparameter_attributes(pairs)
|
2099
|
+
attributes = { }
|
2100
|
+
|
2101
|
+
for pair in pairs
|
2102
|
+
multiparameter_name, value = pair
|
2103
|
+
attribute_name = multiparameter_name.split("(").first
|
2104
|
+
attributes[attribute_name] = [] unless attributes.include?(attribute_name)
|
2105
|
+
|
2106
|
+
unless value.empty?
|
2107
|
+
attributes[attribute_name] <<
|
2108
|
+
[ find_parameter_position(multiparameter_name), type_cast_attribute_value(multiparameter_name, value) ]
|
2109
|
+
end
|
2110
|
+
end
|
2111
|
+
|
2112
|
+
attributes.each { |name, values| attributes[name] = values.sort_by{ |v| v.first }.collect { |v| v.last } }
|
2113
|
+
end
|
2114
|
+
|
2115
|
+
def type_cast_attribute_value(multiparameter_name, value)
|
2116
|
+
multiparameter_name =~ /\([0-9]*([a-z])\)/ ? value.send("to_" + $1) : value
|
2117
|
+
end
|
2118
|
+
|
2119
|
+
def find_parameter_position(multiparameter_name)
|
2120
|
+
multiparameter_name.scan(/\(([0-9]*).*\)/).first.first
|
2121
|
+
end
|
2122
|
+
|
2123
|
+
# Returns a comma-separated pair list, like "key1 = val1, key2 = val2".
|
2124
|
+
def comma_pair_list(hash)
|
2125
|
+
hash.inject([]) { |list, pair| list << "#{pair.first} = #{pair.last}" }.join(", ")
|
2126
|
+
end
|
2127
|
+
|
2128
|
+
def quoted_column_names(attributes = attributes_with_quotes)
|
2129
|
+
attributes.keys.collect do |column_name|
|
2130
|
+
self.class.connection.quote_column_name(column_name)
|
2131
|
+
end
|
2132
|
+
end
|
2133
|
+
|
2134
|
+
def quote_columns(quoter, hash)
|
2135
|
+
hash.inject({}) do |quoted, (name, value)|
|
2136
|
+
quoted[quoter.quote_column_name(name)] = value
|
2137
|
+
quoted
|
2138
|
+
end
|
2139
|
+
end
|
2140
|
+
|
2141
|
+
def quoted_comma_pair_list(quoter, hash)
|
2142
|
+
comma_pair_list(quote_columns(quoter, hash))
|
2143
|
+
end
|
2144
|
+
|
2145
|
+
def object_from_yaml(string)
|
2146
|
+
return string unless string.is_a?(String)
|
2147
|
+
YAML::load(string) rescue string
|
2148
|
+
end
|
2149
|
+
|
2150
|
+
def clone_attributes(reader_method = :read_attribute, attributes = {})
|
2151
|
+
self.attribute_names.inject(attributes) do |attributes, name|
|
2152
|
+
attributes[name] = clone_attribute_value(reader_method, name)
|
2153
|
+
attributes
|
2154
|
+
end
|
2155
|
+
end
|
2156
|
+
|
2157
|
+
def clone_attribute_value(reader_method, attribute_name)
|
2158
|
+
value = send(reader_method, attribute_name)
|
2159
|
+
value.clone
|
2160
|
+
rescue TypeError, NoMethodError
|
2161
|
+
value
|
2162
|
+
end
|
2163
|
+
end
|
2164
|
+
end
|