xhive 1.2.0.pre → 1.2.1.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/app/models/xhive/mapper.rb +17 -3
- data/lib/xhive/version.rb +1 -1
- metadata +3 -3
data/app/models/xhive/mapper.rb
CHANGED
@@ -38,11 +38,23 @@ module Xhive
|
|
38
38
|
#
|
39
39
|
def self.map_resource(site, page, resource, action, key = nil)
|
40
40
|
mapper = find_map(site, resource, action, key)
|
41
|
-
mapper = new(:site_id => site.id, :resource => resource,
|
41
|
+
mapper = new(:site_id => site.id, :resource => resource,
|
42
|
+
:action => action, :key => key.present? ? key : nil) unless mapper.present?
|
42
43
|
mapper.page = page
|
43
44
|
mapper.save
|
44
45
|
end
|
45
46
|
|
47
|
+
# Public: returns all the mappers for a specific resource.
|
48
|
+
#
|
49
|
+
# site - The Site owner of the mappers.
|
50
|
+
# resource - The String containing the resource to filter by.
|
51
|
+
#
|
52
|
+
# Returns: an ActiveRecord::Relation filtered by resource.
|
53
|
+
#
|
54
|
+
def self.all_by_resource(site, resource)
|
55
|
+
where(:site_id => site.id).where(:resource => resource)
|
56
|
+
end
|
57
|
+
|
46
58
|
private
|
47
59
|
|
48
60
|
# Private: looks for a mapper object.
|
@@ -55,8 +67,10 @@ module Xhive
|
|
55
67
|
# Returns: the mapper object or nil if not found.
|
56
68
|
#
|
57
69
|
def self.find_map(site, resource, action, key)
|
58
|
-
mapper = where(:site_id => site.id)
|
59
|
-
mapper = mapper.where(:
|
70
|
+
mapper = where(:site_id => site.id)
|
71
|
+
mapper = mapper.where(:resource => resource)
|
72
|
+
mapper = mapper.where(:action => action)
|
73
|
+
mapper = mapper.where(:key => key.present? ? key : nil)
|
60
74
|
mapper.first
|
61
75
|
end
|
62
76
|
end
|
data/lib/xhive/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xhive
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1.pre
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-11-
|
12
|
+
date: 2012-11-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -297,7 +297,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
297
297
|
version: '0'
|
298
298
|
segments:
|
299
299
|
- 0
|
300
|
-
hash:
|
300
|
+
hash: 2967828758709563627
|
301
301
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
302
302
|
none: false
|
303
303
|
requirements:
|