decent_exposure 2.0.0.rc1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,7 +5,9 @@ module DecentExposure
5
5
  module Expose
6
6
  def self.extended(base)
7
7
  base.class_eval do
8
- class_attribute :_default_exposure
8
+ class_attribute :_default_exposure, :_decent_configurations
9
+ self._decent_configurations ||= Hash.new(Configuration.new)
10
+
9
11
  def _resources
10
12
  @_resources ||= {}
11
13
  end
@@ -17,10 +19,6 @@ module DecentExposure
17
19
  @_exposures ||= {}
18
20
  end
19
21
 
20
- def _decent_configurations
21
- @_decent_configurations ||= Hash.new(Configuration.new)
22
- end
23
-
24
22
  def decent_configuration(name=:default,&block)
25
23
  _decent_configurations[name] = Configuration.new(&block)
26
24
  end
@@ -39,6 +37,13 @@ module DecentExposure
39
37
  end
40
38
 
41
39
  def expose(name, options={:default_exposure => _default_exposure}, &block)
40
+ if ActionController::Base.instance_methods.include?(name.to_sym)
41
+ Kernel.warn "[WARNING] You are exposing the `#{name}` method, " \
42
+ "which overrides an existing ActionController method of the same name. " \
43
+ "Consider a different exposure name\n" \
44
+ "#{caller.first}"
45
+ end
46
+
42
47
  config = options[:config] || :default
43
48
  options = _decent_configurations[config].merge(options)
44
49
 
@@ -3,15 +3,21 @@ require 'active_support/core_ext/string/inflections'
3
3
 
4
4
  module DecentExposure
5
5
  class Inflector
6
- attr_reader :original
7
- alias name original
6
+ attr_reader :string, :original
7
+ alias name string
8
8
 
9
9
  def initialize(name)
10
- @original = name.to_s
10
+ @original = name
11
+ @string = name.to_s.demodulize
11
12
  end
12
13
 
13
- def constant
14
- original.classify.constantize
14
+ def constant(context=Object)
15
+ case original
16
+ when Module, Class
17
+ original
18
+ else
19
+ context.const_get string.classify
20
+ end
15
21
  end
16
22
 
17
23
  def parameter
@@ -19,16 +25,16 @@ module DecentExposure
19
25
  end
20
26
 
21
27
  def singular
22
- original.parameterize
28
+ string.parameterize
23
29
  end
24
30
 
25
31
  def plural
26
- original.pluralize
32
+ string.pluralize
27
33
  end
28
34
  alias collection plural
29
35
 
30
36
  def plural?
31
- plural == original
37
+ plural == string
32
38
  end
33
39
  end
34
40
  end
@@ -17,7 +17,7 @@ module DecentExposure
17
17
  protected
18
18
 
19
19
  def model
20
- inflector.constant
20
+ inflector.constant(controller.class)
21
21
  end
22
22
 
23
23
  def params
@@ -1,3 +1,3 @@
1
1
  module DecentExposure #:nodoc
2
- VERSION = "2.0.0.rc1"
2
+ VERSION = "2.0.0"
3
3
  end
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: decent_exposure
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.rc1
5
- prerelease: 6
4
+ version: 2.0.0
5
+ prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Stephen Caudill
@@ -11,11 +11,11 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-07-27 00:00:00.000000000Z
14
+ date: 2012-10-10 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rspec
18
- requirement: &70110875340260 !ruby/object:Gem::Requirement
18
+ requirement: !ruby/object:Gem::Requirement
19
19
  none: false
20
20
  requirements:
21
21
  - - ~>
@@ -23,10 +23,15 @@ dependencies:
23
23
  version: '2.7'
24
24
  type: :development
25
25
  prerelease: false
26
- version_requirements: *70110875340260
26
+ version_requirements: !ruby/object:Gem::Requirement
27
+ none: false
28
+ requirements:
29
+ - - ~>
30
+ - !ruby/object:Gem::Version
31
+ version: '2.7'
27
32
  - !ruby/object:Gem::Dependency
28
33
  name: rspec-rails
29
- requirement: &70110875338840 !ruby/object:Gem::Requirement
34
+ requirement: !ruby/object:Gem::Requirement
30
35
  none: false
31
36
  requirements:
32
37
  - - ~>
@@ -34,10 +39,15 @@ dependencies:
34
39
  version: '2.7'
35
40
  type: :development
36
41
  prerelease: false
37
- version_requirements: *70110875338840
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '2.7'
38
48
  - !ruby/object:Gem::Dependency
39
49
  name: actionpack
40
- requirement: &70110875338380 !ruby/object:Gem::Requirement
50
+ requirement: !ruby/object:Gem::Requirement
41
51
  none: false
42
52
  requirements:
43
53
  - - ~>
@@ -45,10 +55,15 @@ dependencies:
45
55
  version: '3.1'
46
56
  type: :development
47
57
  prerelease: false
48
- version_requirements: *70110875338380
58
+ version_requirements: !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ~>
62
+ - !ruby/object:Gem::Version
63
+ version: '3.1'
49
64
  - !ruby/object:Gem::Dependency
50
65
  name: activesupport
51
- requirement: &70110875337880 !ruby/object:Gem::Requirement
66
+ requirement: !ruby/object:Gem::Requirement
52
67
  none: false
53
68
  requirements:
54
69
  - - ~>
@@ -56,7 +71,12 @@ dependencies:
56
71
  version: '3.1'
57
72
  type: :development
58
73
  prerelease: false
59
- version_requirements: *70110875337880
74
+ version_requirements: !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ~>
78
+ - !ruby/object:Gem::Version
79
+ version: '3.1'
60
80
  description: ! "\n DecentExposure helps you program to an interface, rather than
61
81
  an\n implementation in your Rails controllers. The fact of the matter is that\n
62
82
  \ sharing state via instance variables in controllers promotes close coupling\n
@@ -100,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
120
  version: 1.3.6
101
121
  requirements: []
102
122
  rubyforge_project:
103
- rubygems_version: 1.8.10
123
+ rubygems_version: 1.8.24
104
124
  signing_key:
105
125
  specification_version: 3
106
126
  summary: A helper for creating declarative interfaces in controllers