resource_awareness 0.0.6 → 0.0.8

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.
@@ -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])
@@ -1,5 +1,10 @@
1
1
  require 'rails/resource'
2
2
  module Rails
3
3
  class SingletonResource < Resource
4
+
5
+ def singleton?
6
+ true
7
+ end
8
+
4
9
  end
5
10
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 6
9
- version: 0.0.6
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-26 00:00:00 +02:00
17
+ date: 2010-04-30 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency