Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Renamed #uri to #normilize_uri on AbstractAdapter. Exposed @uri read …

…only as uri
  • Loading branch information...
commit a535182f90fa29c96ca23d089d1a8894998c60c9 1 parent 5d74448
Guy van den Berg authored
View
9 lib/data_mapper/adapters/abstract_adapter.rb
@@ -3,7 +3,7 @@
module DataMapper
module Adapters
class AbstractAdapter
- attr_reader :name
+ attr_reader :name, :uri
attr_accessor :resource_naming_convention, :field_naming_convention
# Methods dealing with a single resource object
@@ -49,8 +49,9 @@ def delete_set(repository, query)
# raise NotImplementedError
# raise ArgumentError unless block_given?
# end
-
- def uri(uri_or_options)
+
+
+ def normilize_uri(uri_or_options)
uri_or_options
end
@@ -67,7 +68,7 @@ def initialize(name, uri_or_options)
raise ArgumentError, "+uri_or_options+ should be a Hash, a URI or a String but was #{uri_or_options.class}", caller unless [ Hash, URI, String ].any? { |k| k === uri_or_options }
@name = name
- @uri = uri(uri_or_options)
+ @uri = normilize_uri(uri_or_options)
@resource_naming_convention = NamingConventions::UnderscoredAndPluralized
@field_naming_convention = NamingConventions::Underscored
View
2  lib/data_mapper/adapters/data_objects_adapter.rb
@@ -386,7 +386,7 @@ def property_to_column_name(model_name, property, qualify)
include SQL
- def uri(uri_or_options)
+ def normilize_uri(uri_or_options)
uri_or_options = URI.parse(uri_or_options) if String === uri_or_options
return uri_or_options if URI === uri_or_options
View
8 lib/data_mapper/adapters/sqlite3_adapter.rb
@@ -20,10 +20,10 @@ def create_connection
return connnection
end
- def uri(uri_or_options)
- uri = super(uri_or_options)
- uri.path = File.join(Dir.pwd, File.dirname(uri.path), File.basename(uri.path)) unless File.exists?(uri.path)
- uri
+ def normilize_uri(uri_or_options)
+ uri = super(uri_or_options)
+ uri.path = File.join(Dir.pwd, File.dirname(uri.path), File.basename(uri.path)) unless File.exists?(uri.path)
+ uri
end
end # class Sqlite3Adapter
View
6 spec/unit/adapters/data_objects_adapter_spec.rb
@@ -273,7 +273,7 @@ class LittleBox
}
adapter = DataMapper::Adapters::DataObjectsAdapter.allocate
- adapter.uri(options).should ==
+ adapter.normilize_uri(options).should ==
URI.parse("mysql://me:mypass@davidleal.com:5000/you_can_call_me_al?socket=nosock")
end
@@ -284,11 +284,11 @@ class LittleBox
}
adapter = DataMapper::Adapters::DataObjectsAdapter.allocate
- adapter.uri(options).should == URI.parse("mysql:///you_can_call_me_al")
+ adapter.normilize_uri(options).should == URI.parse("mysql:///you_can_call_me_al")
end
it 'should accept the uri when no overrides exist' do
uri = URI.parse("protocol:///")
- DataMapper::Adapters::DataObjectsAdapter.allocate.uri(uri).should == uri
+ DataMapper::Adapters::DataObjectsAdapter.allocate.normilize_uri(uri).should == uri
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.