lib/restfulx.rb in restfulx-1.2.1 vs lib/restfulx.rb in restfulx-1.2.2
- old
+ new
@@ -3,21 +3,14 @@
#
# Loads RestfulX specific rake tasks if appropriate.
module RestfulX
# :stopdoc:
- VERSION = '1.2.1'
- FRAMEWORK_VERSION = '1.2.1'
+ FRAMEWORK_VERSION = '1.2.2'
LIB_DIR = File.join(File.dirname(__FILE__), 'restfulx/')
# :startdoc:
- # Returns the version string for the library.
- #
- def self.version
- VERSION
- end
-
# Utility method used to require all files ending in .rb that lie in the
# directory below this file that has the same name as the filename passed
# in. Optionally, a specific _directory_ name can be passed in such that
# the _filename_ does not have to be equivalent to the directory.
#
@@ -26,11 +19,10 @@
search_me = ::File.expand_path(
::File.join(::File.dirname(fname), dir, '*', '*.rb'))
Dir.glob(search_me).sort.each {|rb| require rb}
end
-
end
require RestfulX::LIB_DIR + 'configuration'
# make sure we're running inside Merb
@@ -52,13 +44,14 @@
end
elsif defined?(ActionController::Base)
# if we are not running in Merb, try to hook up Rails
Mime::Type.register_alias "application/xml", :fxml
- ['active_foo', 'rails/swf_helper'].each { |lib| require RestfulX::LIB_DIR + lib }
+ ['active_foo', 'rails/swf_helper', 'rails/schema_to_yaml'].each { |lib| require RestfulX::LIB_DIR + lib }
- ActionView::Base.send :include, SWFHelper unless ActionView::Base.included_modules.include?(SWFHelper)
+ ActionView::Base.send :include, SWFHelper unless ActionView::Base.included_modules.include?(SWFHelper)
+ ActiveRecord::Migration.send :include, SchemaToYaml
# We mess with default +render+ implementation a bit to add support for expressions
# such as format.fxml { render :fxml => @foo }
module ActionController
# Override render to add support for render :fxml
@@ -76,28 +69,10 @@
old_render(options, extra_options, &block)
end
end
end
end
-
- # It is possible to pass metadata with any RestfulX model. This module adds support for
- # extracting that metadata into the standard params hash.
- module RxController
- private
-
- # Extract any keys named _metadata from the models in the params hash
- # and put them in the root of the params hash.
- def extract_metadata_from_params
- metadata = {}
- metadata.merge!(params.delete('_metadata')) if params.has_key?('_metadata')
- params.each do |k, v|
- next unless v.respond_to?(:has_key?) and v.has_key?('_metadata')
- metadata.merge!(v.delete('_metadata'))
- end
- params.merge!(metadata) unless metadata.empty?
- end
- end
module ActiveRecord
# ActiveRecord named scopes are computed *before* restfulx gem gets loaded
# this patch addresses that and makes sure +to_fxml+ calls are properly
# delegated
@@ -106,15 +81,9 @@
class Scope
delegate :to_fxml, :to => :proxy_found
end
end
end
-
- ActionController::Base.send :include, RxController
- ActionController::Base.send :prepend_before_filter, :extract_metadata_from_params
-
- # temporarily disable forgery protection site-wise
- ActionController::Base.allow_forgery_protection = false
elsif defined?(DataMapper)
require RestfulX::LIB_DIR + 'datamapper_foo'
elsif defined?(ActiveRecord::Base)
require RestfulX::LIB_DIR + 'active_foo'
end
\ No newline at end of file