minimapper 0.2.7 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -1
- data/lib/minimapper/ar.rb +10 -10
- data/lib/minimapper/version.rb +1 -1
- data/minimapper.gemspec +1 -1
- data/spec/ar_spec.rb +1 -1
- metadata +7 -7
data/README.md
CHANGED
@@ -154,7 +154,7 @@ end
|
|
154
154
|
module AR
|
155
155
|
class ProjectMapper < Minimapper::AR
|
156
156
|
def waiting_for_review
|
157
|
-
|
157
|
+
record_class.where(waiting_for_review: true).order("id DESC").map do |record|
|
158
158
|
entity_for(record)
|
159
159
|
end
|
160
160
|
end
|
data/lib/minimapper/ar.rb
CHANGED
@@ -7,7 +7,7 @@ module Minimapper
|
|
7
7
|
# Create
|
8
8
|
def create(entity)
|
9
9
|
if entity.valid?
|
10
|
-
entity.id =
|
10
|
+
entity.id = record_class.create!(accessible_attributes(entity)).id
|
11
11
|
else
|
12
12
|
false
|
13
13
|
end
|
@@ -23,19 +23,19 @@ module Minimapper
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def all
|
26
|
-
entities_for
|
26
|
+
entities_for record_class.all
|
27
27
|
end
|
28
28
|
|
29
29
|
def first
|
30
|
-
entity_for(
|
30
|
+
entity_for(record_class.order("id ASC").first)
|
31
31
|
end
|
32
32
|
|
33
33
|
def last
|
34
|
-
entity_for(
|
34
|
+
entity_for(record_class.order("id ASC").last)
|
35
35
|
end
|
36
36
|
|
37
37
|
def count
|
38
|
-
|
38
|
+
record_class.count
|
39
39
|
end
|
40
40
|
|
41
41
|
# Update
|
@@ -59,7 +59,7 @@ module Minimapper
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def delete_all
|
62
|
-
|
62
|
+
record_class.delete_all
|
63
63
|
end
|
64
64
|
|
65
65
|
private
|
@@ -68,7 +68,7 @@ module Minimapper
|
|
68
68
|
|
69
69
|
# Will attempt to use AR:Project as the record class
|
70
70
|
# when the mapper class name is AR::ProjectMapper
|
71
|
-
def
|
71
|
+
def record_class
|
72
72
|
self.class.name.gsub(/Mapper/, '').constantize
|
73
73
|
end
|
74
74
|
|
@@ -83,7 +83,7 @@ module Minimapper
|
|
83
83
|
end
|
84
84
|
|
85
85
|
def protected_attributes
|
86
|
-
|
86
|
+
record_class.protected_attributes
|
87
87
|
end
|
88
88
|
|
89
89
|
def find_record_safely(id)
|
@@ -92,11 +92,11 @@ module Minimapper
|
|
92
92
|
end
|
93
93
|
|
94
94
|
def find_record(id)
|
95
|
-
id &&
|
95
|
+
id && record_class.find_by_id(id)
|
96
96
|
end
|
97
97
|
|
98
98
|
def record_for(entity)
|
99
|
-
(entity.id &&
|
99
|
+
(entity.id && record_class.find_by_id(entity.id)) ||
|
100
100
|
raise(Common::CanNotFindEntity, entity.inspect)
|
101
101
|
end
|
102
102
|
|
data/lib/minimapper/version.rb
CHANGED
data/minimapper.gemspec
CHANGED
@@ -6,7 +6,7 @@ require 'minimapper/version'
|
|
6
6
|
Gem::Specification.new do |gem|
|
7
7
|
gem.name = "minimapper"
|
8
8
|
gem.version = Minimapper::VERSION
|
9
|
-
gem.authors = ["Joakim
|
9
|
+
gem.authors = ["Joakim Kolsjo"]
|
10
10
|
gem.email = ["joakim.kolsjo@gmail.com"]
|
11
11
|
gem.description = %q{A minimalistic way of separating your models from ORMs like ActiveRecord.}
|
12
12
|
gem.summary = %q{A minimalistic way of separating your models from ORMs like ActiveRecord.}
|
data/spec/ar_spec.rb
CHANGED
metadata
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minimapper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
|
-
- Joakim
|
8
|
+
- Joakim Kolsjo
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-03-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
16
|
-
requirement: &
|
16
|
+
requirement: &70114985880520 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70114985880520
|
25
25
|
description: A minimalistic way of separating your models from ORMs like ActiveRecord.
|
26
26
|
email:
|
27
27
|
- joakim.kolsjo@gmail.com
|
@@ -77,7 +77,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
77
77
|
version: '0'
|
78
78
|
segments:
|
79
79
|
- 0
|
80
|
-
hash:
|
80
|
+
hash: 1267216802408816283
|
81
81
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
82
|
none: false
|
83
83
|
requirements:
|
@@ -86,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
86
86
|
version: '0'
|
87
87
|
segments:
|
88
88
|
- 0
|
89
|
-
hash:
|
89
|
+
hash: 1267216802408816283
|
90
90
|
requirements: []
|
91
91
|
rubyforge_project:
|
92
92
|
rubygems_version: 1.8.5
|