dm-active_model 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/dm-active_model.gemspec +3 -2
- data/lib/dm-active_model/extlib.rb +28 -0
- data/lib/dm-active_model/version.rb +1 -1
- data/lib/dm-active_model.rb +7 -20
- metadata +3 -2
data/dm-active_model.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{dm-active_model}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Martin Gamsjaeger (snusnu)"]
|
12
|
-
s.date = %q{
|
12
|
+
s.date = %q{2010-01-14}
|
13
13
|
s.description = %q{A datamapper plugin for active_model compliance and thus rails 3 compatibility.}
|
14
14
|
s.email = %q{gamsnjaga [a] gmail [d] com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -27,6 +27,7 @@ Gem::Specification.new do |s|
|
|
27
27
|
"TODO",
|
28
28
|
"dm-active_model.gemspec",
|
29
29
|
"lib/dm-active_model.rb",
|
30
|
+
"lib/dm-active_model/extlib.rb",
|
30
31
|
"lib/dm-active_model/version.rb",
|
31
32
|
"spec/amo_compliance_spec.rb",
|
32
33
|
"spec/dm-active_model_spec.rb",
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'extlib/inflection'
|
2
|
+
|
3
|
+
module ActiveSupport
|
4
|
+
Inflector = Extlib::Inflection
|
5
|
+
end
|
6
|
+
|
7
|
+
module ActiveModel
|
8
|
+
|
9
|
+
# This is mostly copied from active_model and adapted to use extlib under the hood.
|
10
|
+
# see http://github.com/rails/rails/blob/master/activemodel/lib/active_model/naming.rb
|
11
|
+
class Name < String
|
12
|
+
|
13
|
+
attr_reader :singular, :plural, :element, :collection, :partial_path, :human
|
14
|
+
alias_method :cache_key, :collection
|
15
|
+
|
16
|
+
def initialize(klass)
|
17
|
+
super(klass.name)
|
18
|
+
@singular = Extlib::Inflection.underscore(self).tr('/', '_').freeze
|
19
|
+
@plural = Extlib::Inflection.pluralize(@singular).freeze
|
20
|
+
@element = Extlib::Inflection.underscore(Extlib::Inflection.demodulize(self)).freeze
|
21
|
+
@human = Extlib::Inflection.humanize(@element)
|
22
|
+
@collection = Extlib::Inflection.pluralize(Extlib::Inflection.underscore(self)).freeze
|
23
|
+
@partial_path = "#{@collection}/#{@element}".freeze
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
data/lib/dm-active_model.rb
CHANGED
@@ -1,31 +1,18 @@
|
|
1
|
+
if Object.const_defined?('Extlib')
|
2
|
+
require 'dm-active_model/extlib'
|
3
|
+
else
|
4
|
+
require 'active_model/naming'
|
5
|
+
end
|
6
|
+
|
1
7
|
module DataMapper
|
2
8
|
module ActiveModel
|
3
9
|
|
4
|
-
# This is mostly copied from active_model and adapted to use extlib under the hood.
|
5
|
-
# see http://github.com/rails/rails/blob/master/activemodel/lib/active_model/naming.rb
|
6
|
-
class Name < String
|
7
|
-
|
8
|
-
attr_reader :singular, :plural, :element, :collection, :partial_path, :human
|
9
|
-
alias_method :cache_key, :collection
|
10
|
-
|
11
|
-
def initialize(name)
|
12
|
-
super
|
13
|
-
@singular = Extlib::Inflection.underscore(self).tr('/', '_').freeze
|
14
|
-
@plural = Extlib::Inflection.pluralize(@singular).freeze
|
15
|
-
@element = Extlib::Inflection.underscore(Extlib::Inflection.demodulize(self)).freeze
|
16
|
-
@human = Extlib::Inflection.humanize(@element)
|
17
|
-
@collection = Extlib::Inflection.pluralize(Extlib::Inflection.underscore(self)).freeze
|
18
|
-
@partial_path = "#{@collection}/#{@element}".freeze
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
10
|
module ClassMethods
|
24
11
|
|
25
12
|
# Returns an ActiveModel::Name object for module. It can be
|
26
13
|
# used to retrieve all kinds of naming-related information.
|
27
14
|
def model_name
|
28
|
-
@_model_name ||=
|
15
|
+
@_model_name ||= ::ActiveModel::Name.new(self)
|
29
16
|
end
|
30
17
|
|
31
18
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dm-active_model
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Gamsjaeger (snusnu)
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2010-01-14 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -62,6 +62,7 @@ files:
|
|
62
62
|
- TODO
|
63
63
|
- dm-active_model.gemspec
|
64
64
|
- lib/dm-active_model.rb
|
65
|
+
- lib/dm-active_model/extlib.rb
|
65
66
|
- lib/dm-active_model/version.rb
|
66
67
|
- spec/amo_compliance_spec.rb
|
67
68
|
- spec/dm-active_model_spec.rb
|