aboutsummaryrefslogtreecommitdiffstats
path: root/activeresource/lib
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2009-12-20 18:44:13 -0600
committerJoshua Peek <josh@joshpeek.com>2009-12-20 19:04:53 -0600
commit669c5eec445ff097b765c387b92ae1f174134f75 (patch)
treee6f61ae232e30a5a57ae3b935e271586803f0814 /activeresource/lib
parentfc9b3e4a45a81b7526f8154049c825e3755903ad (diff)
downloadrails-669c5eec445ff097b765c387b92ae1f174134f75.tar.gz
rails-669c5eec445ff097b765c387b92ae1f174134f75.tar.bz2
rails-669c5eec445ff097b765c387b92ae1f174134f75.zip
Rename SchemaDefinition => Schema
Diffstat (limited to 'activeresource/lib')
-rw-r--r--activeresource/lib/active_resource.rb3
-rw-r--r--activeresource/lib/active_resource/base.rb15
-rw-r--r--activeresource/lib/active_resource/schema.rb (renamed from activeresource/lib/active_resource/schema_definition.rb)8
3 files changed, 13 insertions, 13 deletions
diff --git a/activeresource/lib/active_resource.rb b/activeresource/lib/active_resource.rb
index 84baf4227a..3e4a1dd4a1 100644
--- a/activeresource/lib/active_resource.rb
+++ b/activeresource/lib/active_resource.rb
@@ -37,7 +37,8 @@ module ActiveResource
autoload :Connection
autoload :CustomMethods
autoload :Formats
+ autoload :HttpMock
autoload :Observing
+ autoload :Schema
autoload :Validations
- autoload :HttpMock
end
diff --git a/activeresource/lib/active_resource/base.rb b/activeresource/lib/active_resource/base.rb
index 60bd573911..b39f8fbd48 100644
--- a/activeresource/lib/active_resource/base.rb
+++ b/activeresource/lib/active_resource/base.rb
@@ -13,7 +13,6 @@ require 'set'
require 'uri'
require 'active_resource/exceptions'
-require 'active_resource/schema_definition'
module ActiveResource
# ActiveResource::Base is the main class for mapping RESTful resources as models in a Rails application.
@@ -270,9 +269,9 @@ module ActiveResource
# s.integer 'age'
# s.float 'height', 'weight'
#
- # # unsupported types should be left as strings
+ # # unsupported types should be left as strings
# # overload the accessor methods if you need to convert them
- # s.attribute 'created_at', 'string'
+ # s.attribute 'created_at', 'string'
# end
# end
#
@@ -295,14 +294,14 @@ module ActiveResource
# string, integer, float
#
# Note: at present the attribute-type doesn't do anything, but stay
- # tuned...
+ # tuned...
# Shortly it will also *cast* the value of the returned attribute.
# ie:
# j.age # => 34 # cast to an integer
# j.weight # => '65' # still a string!
#
def define_schema
- schema_definition = SchemaDefinition.new
+ schema_definition = Schema.new
yield schema_definition if block_given?
# skip out if we didn't define anything
@@ -317,7 +316,7 @@ module ActiveResource
end
schema
- end
+ end
# Alternative, direct way to specify a <tt>schema</tt> for this
@@ -326,7 +325,7 @@ module ActiveResource
#
# Pass the schema as a hash with the keys being the attribute-names
# and the value being one of the accepted attribute types (as defined
- # in <tt>define_schema</tt>)
+ # in <tt>define_schema</tt>)
#
# example:
#
@@ -342,7 +341,7 @@ module ActiveResource
# purposefully nulling out the schema
@schema = nil
@known_attributes = []
- return
+ return
end
raise ArgumentError, "Expected a hash" unless the_schema.kind_of? Hash
diff --git a/activeresource/lib/active_resource/schema_definition.rb b/activeresource/lib/active_resource/schema.rb
index abcbf3ba4e..498b00ffef 100644
--- a/activeresource/lib/active_resource/schema_definition.rb
+++ b/activeresource/lib/active_resource/schema.rb
@@ -1,7 +1,7 @@
require 'active_resource/exceptions'
module ActiveResource # :nodoc:
- class SchemaDefinition # :nodoc:
+ class Schema # :nodoc:
# attributes can be known to be one of these types. They are easy to
# cast to/from.
@@ -11,7 +11,7 @@ module ActiveResource # :nodoc:
# have been defined.
attr_accessor :attrs
- # The internals of an Active Resource SchemaDefinition are very simple -
+ # The internals of an Active Resource Schema are very simple -
# unlike an Active Record TableDefinition (on which it is based).
# It provides a set of convenience methods for people to define their
# schema using the syntax:
@@ -28,7 +28,7 @@ module ActiveResource # :nodoc:
end
def attribute(name, type, options = {})
- raise ArgumentError, "Unknown Attribute type: #{type.inspect} for key: #{name.inspect}" unless type.nil? || SchemaDefinition::KNOWN_ATTRIBUTE_TYPES.include?(type.to_s)
+ raise ArgumentError, "Unknown Attribute type: #{type.inspect} for key: #{name.inspect}" unless type.nil? || Schema::KNOWN_ATTRIBUTE_TYPES.include?(type.to_s)
the_type = type.to_s
# TODO: add defaults
@@ -39,7 +39,7 @@ module ActiveResource # :nodoc:
end
# The following are the attribute types supported by Active Resource
- # migrations.
+ # migrations.
# TODO: We should eventually support all of these:
# %w( string text integer float decimal datetime timestamp time date binary boolean ).each do |attr_type|
KNOWN_ATTRIBUTE_TYPES.each do |attr_type|