resource_awareness 0.0.6 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rails/resource.rb +6 -1
- data/lib/rails/singleton_resource.rb +5 -0
- metadata +3 -3
data/lib/rails/resource.rb
CHANGED
@@ -2,7 +2,7 @@ require 'builder'
|
|
2
2
|
|
3
3
|
module Rails
|
4
4
|
class Resource
|
5
|
-
attr_accessor :id, :name, :singular_name, :controller_path, :name_prefix, :path_prefix, :home_route
|
5
|
+
attr_accessor :id, :name, :singular_name, :controller_path, :name_prefix, :path_prefix, :prefix_parameters, :home_route
|
6
6
|
|
7
7
|
def initialize(entity, scope, options)
|
8
8
|
self.name_prefix = scope[:name_prefix]
|
@@ -12,6 +12,7 @@ module Rails
|
|
12
12
|
self.home_route = Rails.application.routes.named_routes[id]
|
13
13
|
self.path_prefix = home_route.path.sub("/#{name}(.:format)", '')
|
14
14
|
self.path_prefix = nil if path_prefix.blank?
|
15
|
+
self.prefix_parameters = home_route.segment_keys.find_all{|sk| sk.to_s.match(/_id\Z/)}.to_set
|
15
16
|
self.controller_path = home_route.requirements[:controller]
|
16
17
|
end
|
17
18
|
|
@@ -19,6 +20,10 @@ module Rails
|
|
19
20
|
path_prefix ? "#{path_prefix}/#{name}" : "/#{name}"
|
20
21
|
end
|
21
22
|
|
23
|
+
def singleton?
|
24
|
+
false
|
25
|
+
end
|
26
|
+
|
22
27
|
def to_xml(options = {})
|
23
28
|
options[:indent] ||= 2
|
24
29
|
xml = options[:builder] ||= Builder::XmlMarkup.new(:indent => options[:indent])
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 8
|
9
|
+
version: 0.0.8
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Ingo Weiss
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-04-
|
17
|
+
date: 2010-04-30 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|