grape-entity 0.4.7 → 0.4.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2a2e44f74dcea5b8a3246cff9b4e37e9bb41ebe3
4
- data.tar.gz: 73cd0f7449e63b8a23db6930216b45cc1346e620
3
+ metadata.gz: 4da3e754b2801be8d8801bf8cc483e457261bee9
4
+ data.tar.gz: f5bda0779d4bb3bb76f43f4b6c1207d2b0e8f1d3
5
5
  SHA512:
6
- metadata.gz: 434022e3992890cd9328770146b07156ba5ce0ff64321f659b7216cae73f06e426a5b800caf4f47338e7ef665d1e66352cda437203a57601b1bc47ffb50a28bf
7
- data.tar.gz: 87e69046e3564712b3648ba10f05f8166e77230503cb0561808302987823494cbb2f540219fa0ae9422994b38a38bbc144b15236e6a2f6bf1c129f134f69f67c
6
+ metadata.gz: 3c12c01509079508b09981d5f4196f489b38be1d23d33f1dd9db9b0e9f2f1f637b83e87e57ad6a2c98ba59cd0a570520960ad4926ba959e895f9a7cffce31f5e
7
+ data.tar.gz: 09f153d167e0e0f5e8007d3947660fa9b2723c46a9ca925b257709e6e5209b8d7fca8ef5ede080d8b50b294dfb04a3a5d1bfb7037b97996677dc048c50720440
data/.rubocop_todo.yml CHANGED
@@ -1,38 +1,38 @@
1
1
  # This configuration was generated by `rubocop --auto-gen-config`
2
- # on 2015-05-21 22:47:03 +0700 using RuboCop version 0.31.0.
2
+ # on 2015-08-10 12:30:52 +0300 using RuboCop version 0.31.0.
3
3
  # The point is for the user to remove these configuration records
4
4
  # one by one as the offenses are removed from the code base.
5
5
  # Note that changes in the inspected code, or installation of new
6
6
  # versions of RuboCop, may require this file to be generated again.
7
7
 
8
- # Offense count: 8
8
+ # Offense count: 7
9
9
  Metrics/AbcSize:
10
- Max: 51
10
+ Max: 45
11
11
 
12
12
  # Offense count: 1
13
13
  # Configuration parameters: CountComments.
14
14
  Metrics/ClassLength:
15
- Max: 328
15
+ Max: 333
16
16
 
17
- # Offense count: 5
17
+ # Offense count: 4
18
18
  Metrics/CyclomaticComplexity:
19
19
  Max: 17
20
20
 
21
- # Offense count: 176
21
+ # Offense count: 193
22
22
  # Configuration parameters: AllowURI, URISchemes.
23
23
  Metrics/LineLength:
24
24
  Max: 146
25
25
 
26
- # Offense count: 7
26
+ # Offense count: 8
27
27
  # Configuration parameters: CountComments.
28
28
  Metrics/MethodLength:
29
- Max: 32
29
+ Max: 26
30
30
 
31
- # Offense count: 5
31
+ # Offense count: 7
32
32
  Metrics/PerceivedComplexity:
33
33
  Max: 15
34
34
 
35
- # Offense count: 31
35
+ # Offense count: 37
36
36
  Style/Documentation:
37
37
  Enabled: false
38
38
 
data/CHANGELOG.md CHANGED
@@ -1,76 +1,80 @@
1
+ 0.4.8 (2015-08-10)
2
+ ==================
3
+ * [#167](https://github.com/ruby-grape/grape-entity/pull/167): Regression: global settings (exposures, formatters) on `Grape::Entity` should work: [#166](https://github.com/ruby-grape/grape-entity/issues/166) - [@marshall-lee](http://github.com/marshall-lee).
4
+
1
5
  0.4.7 (2015-08-03)
2
6
  ==================
3
- * [#164](https://github.com/intridea/grape-entity/pull/164): Regression: entity instance methods were exposed with `NoMethodError`: [#163](https://github.com/intridea/grape-entity/issues/163) - [@marshall-lee](http://github.com/marshall-lee).
7
+ * [#164](https://github.com/ruby-grape/grape-entity/pull/164): Regression: entity instance methods were exposed with `NoMethodError`: [#163](https://github.com/ruby-grape/grape-entity/issues/163) - [@marshall-lee](http://github.com/marshall-lee).
4
8
 
5
9
  0.4.6 (2015-07-27)
6
10
  ==================
7
11
 
8
- * [#114](https://github.com/intridea/grape-entity/pull/114): Added 'only' option that selects which attributes should be returned - [@estevaoam](https://github.com/estevaoam).
9
- * [#115](https://github.com/intridea/grape-entity/pull/115): Allowing 'root' to be inherited from parent to child entities - [@guidoprincess](https://github.com/guidoprincess).
10
- * [#121](https://github.com/intridea/grape-entity/pull/122): Sublcassed Entity#documentation properly handles unexposed params - [@dan-corneanu](https://github.com/dan-corneanu).
11
- * [#134](https://github.com/intridea/grape-entity/pull/134): Subclasses no longer affected in all cases by `unexpose` in parent - [@etehtsea](https://github.com/etehtsea).
12
- * [#135](https://github.com/intridea/grape-entity/pull/135): Added `except` option - [@dan-corneanu](https://github.com/dan-corneanu).
13
- * [#136](https://github.com/intridea/grape-entity/pull/136): Allow for strings in `only` and `except` options - [@bswinnerton](https://github.com/bswinnerton).
14
- * [#147](https://github.com/intridea/grape-entity/pull/147): Expose `safe` attributes as `nil` if they cannot be evaluated: [#140](https://github.com/intridea/grape-entity/issues/140) - [@marshall-lee](http://github.com/marshall-lee).
15
- * [#147](https://github.com/intridea/grape-entity/pull/147): Fix: private method values were not exposed with `safe` option: [#142](https://github.com/intridea/grape-entity/pull/142) - [@marshall-lee](http://github.com/marshall-lee).
16
- * [#147](https://github.com/intridea/grape-entity/pull/147): Remove catching of `NoMethodError` because it can occur deep inside in a method call so this exception does not mean that attribute not exist - [@marshall-lee](http://github.com/marshall-lee).
17
- * [#147](https://github.com/intridea/grape-entity/pull/147): `valid_exposures` is removed - [@marshall-lee](http://github.com/marshall-lee).
12
+ * [#114](https://github.com/ruby-grape/grape-entity/pull/114): Added 'only' option that selects which attributes should be returned - [@estevaoam](https://github.com/estevaoam).
13
+ * [#115](https://github.com/ruby-grape/grape-entity/pull/115): Allowing 'root' to be inherited from parent to child entities - [@guidoprincess](https://github.com/guidoprincess).
14
+ * [#121](https://github.com/ruby-grape/grape-entity/pull/122): Sublcassed Entity#documentation properly handles unexposed params - [@dan-corneanu](https://github.com/dan-corneanu).
15
+ * [#134](https://github.com/ruby-grape/grape-entity/pull/134): Subclasses no longer affected in all cases by `unexpose` in parent - [@etehtsea](https://github.com/etehtsea).
16
+ * [#135](https://github.com/ruby-grape/grape-entity/pull/135): Added `except` option - [@dan-corneanu](https://github.com/dan-corneanu).
17
+ * [#136](https://github.com/ruby-grape/grape-entity/pull/136): Allow for strings in `only` and `except` options - [@bswinnerton](https://github.com/bswinnerton).
18
+ * [#147](https://github.com/ruby-grape/grape-entity/pull/147): Expose `safe` attributes as `nil` if they cannot be evaluated: [#140](https://github.com/ruby-grape/grape-entity/issues/140) - [@marshall-lee](http://github.com/marshall-lee).
19
+ * [#147](https://github.com/ruby-grape/grape-entity/pull/147): Fix: private method values were not exposed with `safe` option: [#142](https://github.com/ruby-grape/grape-entity/pull/142) - [@marshall-lee](http://github.com/marshall-lee).
20
+ * [#147](https://github.com/ruby-grape/grape-entity/pull/147): Remove catching of `NoMethodError` because it can occur deep inside in a method call so this exception does not mean that attribute not exist - [@marshall-lee](http://github.com/marshall-lee).
21
+ * [#147](https://github.com/ruby-grape/grape-entity/pull/147): `valid_exposures` is removed - [@marshall-lee](http://github.com/marshall-lee).
18
22
 
19
23
  0.4.5 (2015-03-10)
20
24
  ==================
21
25
 
22
- * [#109](https://github.com/intridea/grape-entity/pull/109): Added `unexpose` method - [@jonmchan](https://github.com/jonmchan).
23
- * [#98](https://github.com/intridea/grape-entity/pull/98): Added nested conditionals - [@zbelzer](https://github.com/zbelzer).
24
- * [#105](https://github.com/intridea/grape-entity/pull/105): Specify which attribute is missing in which Entity - [@jhollinger](https://github.com/jhollinger).
25
- * [#111](https://github.com/intridea/grape-entity/pull/111): Fix: allow usage of attributes with name 'key' if `Hash` objects are used - [@croeck](https://github.com/croeck).
26
- * [#110](https://github.com/intridea/grape-entity/pull/110): Fix: safe exposure when using `Hash` models - [@croeck](https://github.com/croeck).
27
- * [#91](https://github.com/intridea/grape-entity/pull/91): Fix: OpenStruct serializing - [@etehtsea](https://github.com/etehtsea).
26
+ * [#109](https://github.com/ruby-grape/grape-entity/pull/109): Added `unexpose` method - [@jonmchan](https://github.com/jonmchan).
27
+ * [#98](https://github.com/ruby-grape/grape-entity/pull/98): Added nested conditionals - [@zbelzer](https://github.com/zbelzer).
28
+ * [#105](https://github.com/ruby-grape/grape-entity/pull/105): Specify which attribute is missing in which Entity - [@jhollinger](https://github.com/jhollinger).
29
+ * [#111](https://github.com/ruby-grape/grape-entity/pull/111): Fix: allow usage of attributes with name 'key' if `Hash` objects are used - [@croeck](https://github.com/croeck).
30
+ * [#110](https://github.com/ruby-grape/grape-entity/pull/110): Fix: safe exposure when using `Hash` models - [@croeck](https://github.com/croeck).
31
+ * [#91](https://github.com/ruby-grape/grape-entity/pull/91): Fix: OpenStruct serializing - [@etehtsea](https://github.com/etehtsea).
28
32
 
29
33
  0.4.4 (2014-08-17)
30
34
  ==================
31
35
 
32
- * [#85](https://github.com/intridea/grape-entity/pull/85): Added `present_collection` to indicate that an `Entity` presents an entire Collection - [@dspaeth-faber](https://github.com/dspaeth-faber).
33
- * [#85](https://guthub.com/intridea/grape-entity/pull/85): Hashes can now be passed as object to be presented and the `Hash` keys can be referenced by expose - [@dspaeth-faber](https://github.com/dspaeth-faber).
36
+ * [#85](https://github.com/ruby-grape/grape-entity/pull/85): Added `present_collection` to indicate that an `Entity` presents an entire Collection - [@dspaeth-faber](https://github.com/dspaeth-faber).
37
+ * [#85](https://guthub.com/ruby-grape/grape-entity/pull/85): Hashes can now be passed as object to be presented and the `Hash` keys can be referenced by expose - [@dspaeth-faber](https://github.com/dspaeth-faber).
34
38
 
35
39
  0.4.3 (2014-06-12)
36
40
  ==================
37
41
 
38
- * [#77](https://github.com/intridea/grape-entity/pull/77): Fix: compatibility with Rspec 3 - [@justfalter](https://github.com/justfalter).
39
- * [#76](https://github.com/intridea/grape-entity/pull/76): Improve performance of entity serialization - [@justfalter](https://github.com/justfalter)
42
+ * [#77](https://github.com/ruby-grape/grape-entity/pull/77): Fix: compatibility with Rspec 3 - [@justfalter](https://github.com/justfalter).
43
+ * [#76](https://github.com/ruby-grape/grape-entity/pull/76): Improve performance of entity serialization - [@justfalter](https://github.com/justfalter)
40
44
 
41
45
  0.4.2 (2014-04-03)
42
46
  ==================
43
47
 
44
- * [#60](https://github.com/intridea/grape-entity/issues/59): Performance issues introduced by nested exposures - [@AlexYankee](https://github.com/AlexYankee).
45
- * [#60](https://github.com/intridea/grape-entity/issues/57): Nested exposure double-exposes a field - [@AlexYankee](https://github.com/AlexYankee).
48
+ * [#60](https://github.com/ruby-grape/grape-entity/issues/59): Performance issues introduced by nested exposures - [@AlexYankee](https://github.com/AlexYankee).
49
+ * [#60](https://github.com/ruby-grape/grape-entity/issues/57): Nested exposure double-exposes a field - [@AlexYankee](https://github.com/AlexYankee).
46
50
 
47
51
  0.4.1 (2014-02-13)
48
52
  ==================
49
53
 
50
- * [#54](https://github.com/intridea/grape-entity/issues/54): Fix: undefined method `to_set` - [@aj0strow](https://github.com/aj0strow).
54
+ * [#54](https://github.com/ruby-grape/grape-entity/issues/54): Fix: undefined method `to_set` - [@aj0strow](https://github.com/aj0strow).
51
55
 
52
56
  0.4.0 (2014-01-27)
53
57
  ==================
54
58
 
55
59
  * Ruby 1.8.x is no longer supported - [@dblock](https://github.com/dblock).
56
- * [#36](https://github.com/intridea/grape-entity/pull/36): Enforcing Ruby style guidelines via Rubocop - [@dblock](https://github.com/dblock).
57
- * [#7](https://github.com/intridea/grape-entity/issues/7): Added `serializable` option to `represent` - [@mbleigh](https://github.com/mbleigh).
58
- * [#18](https://github.com/intridea/grape-entity/pull/18): Added `safe` option to `expose`, will not raise error for a missing attribute - [@fixme](https://github.com/fixme).
59
- * [#16](https://github.com/intridea/grape-entity/pull/16): Added `using` option to `expose SYMBOL BLOCK` - [@fahchen](https://github.com/fahchen).
60
- * [#24](https://github.com/intridea/grape-entity/pull/24): Return documentation with `as` param considered - [@drakula2k](https://github.com/drakula2k).
61
- * [#27](https://github.com/intridea/grape-entity/pull/27): Properly serialize hashes - [@clintonb](https://github.com/clintonb).
62
- * [#28](https://github.com/intridea/grape-entity/pull/28): Look for method on entity before calling it on the object - [@MichaelXavier](https://github.com/MichaelXavier).
63
- * [#33](https://github.com/intridea/grape-entity/pull/33): Support proper merging of nested conditionals - [@wyattisimo](https://github.com/wyattisimo).
64
- * [#43](https://github.com/intridea/grape-entity/pull/43): Call procs in context of entity instance - [@joelvh](https://github.com/joelvh).
65
- * [#47](https://github.com/intridea/grape-entity/pull/47): Support nested exposures - [@wyattisimo](https://github.com/wyattisimo).
66
- * [#46](https://github.com/intridea/grape-entity/issues/46), [#50](https://github.com/intridea/grape-entity/pull/50): Added support for specifying the presenter class in `using` in string format - [@larryzhao](https://github.com/larryzhao).
67
- * [#51](https://github.com/intridea/grape-entity/pull/51): Raise `ArgumentError` if an unknown option is used with `expose` - [@aj0strow](https://github.com/aj0strow).
68
- * [#51](https://github.com/intridea/grape-entity/pull/51): Alias `:with` to `:using`, consistently with the Grape api endpoints - [@aj0strow](https://github.com/aj0strow).
60
+ * [#36](https://github.com/ruby-grape/grape-entity/pull/36): Enforcing Ruby style guidelines via Rubocop - [@dblock](https://github.com/dblock).
61
+ * [#7](https://github.com/ruby-grape/grape-entity/issues/7): Added `serializable` option to `represent` - [@mbleigh](https://github.com/mbleigh).
62
+ * [#18](https://github.com/ruby-grape/grape-entity/pull/18): Added `safe` option to `expose`, will not raise error for a missing attribute - [@fixme](https://github.com/fixme).
63
+ * [#16](https://github.com/ruby-grape/grape-entity/pull/16): Added `using` option to `expose SYMBOL BLOCK` - [@fahchen](https://github.com/fahchen).
64
+ * [#24](https://github.com/ruby-grape/grape-entity/pull/24): Return documentation with `as` param considered - [@drakula2k](https://github.com/drakula2k).
65
+ * [#27](https://github.com/ruby-grape/grape-entity/pull/27): Properly serialize hashes - [@clintonb](https://github.com/clintonb).
66
+ * [#28](https://github.com/ruby-grape/grape-entity/pull/28): Look for method on entity before calling it on the object - [@MichaelXavier](https://github.com/MichaelXavier).
67
+ * [#33](https://github.com/ruby-grape/grape-entity/pull/33): Support proper merging of nested conditionals - [@wyattisimo](https://github.com/wyattisimo).
68
+ * [#43](https://github.com/ruby-grape/grape-entity/pull/43): Call procs in context of entity instance - [@joelvh](https://github.com/joelvh).
69
+ * [#47](https://github.com/ruby-grape/grape-entity/pull/47): Support nested exposures - [@wyattisimo](https://github.com/wyattisimo).
70
+ * [#46](https://github.com/ruby-grape/grape-entity/issues/46), [#50](https://github.com/ruby-grape/grape-entity/pull/50): Added support for specifying the presenter class in `using` in string format - [@larryzhao](https://github.com/larryzhao).
71
+ * [#51](https://github.com/ruby-grape/grape-entity/pull/51): Raise `ArgumentError` if an unknown option is used with `expose` - [@aj0strow](https://github.com/aj0strow).
72
+ * [#51](https://github.com/ruby-grape/grape-entity/pull/51): Alias `:with` to `:using`, consistently with the Grape api endpoints - [@aj0strow](https://github.com/aj0strow).
69
73
 
70
74
  0.3.0 (2013-03-29)
71
75
  ==================
72
76
 
73
- * [#9](https://github.com/intridea/grape-entity/pull/9): Added `with_options` for block-level exposure setting - [@SegFaultAX](https://github.com/SegFaultAX).
77
+ * [#9](https://github.com/ruby-grape/grape-entity/pull/9): Added `with_options` for block-level exposure setting - [@SegFaultAX](https://github.com/SegFaultAX).
74
78
  * The `instance.entity` method now optionally accepts `options` - [@mbleigh](https://github.com/mbleigh).
75
79
  * You can pass symbols to `:if` and `:unless` to simply check for truthiness/falsiness of the specified options key - [@mbleigh](https://github.com/mbleigh).
76
80
 
data/CONTRIBUTING.md CHANGED
@@ -1,16 +1,16 @@
1
1
  Contributing to Grape-Entity
2
2
  ============================
3
3
 
4
- Grape-Entity is work of [many of contributors](https://github.com/intridea/grape-entity/graphs/contributors). You're encouraged to submit [pull requests](https://github.com/intridea/grape-entity/pulls), [propose features and discuss issues](https://github.com/intridea/grape-entity/issues). When in doubt, ask a question in the [Grape Google Group](http://groups.google.com/group/ruby-grape).
4
+ Grape-Entity is work of [many of contributors](https://github.com/ruby-grape/grape-entity/graphs/contributors). You're encouraged to submit [pull requests](https://github.com/ruby-grape/grape-entity/pulls), [propose features and discuss issues](https://github.com/ruby-grape/grape-entity/issues). When in doubt, ask a question in the [Grape Google Group](http://groups.google.com/group/ruby-grape).
5
5
 
6
6
  #### Fork the Project
7
7
 
8
- Fork the [project on Github](https://github.com/intridea/grape-entity) and check out your copy.
8
+ Fork the [project on Github](https://github.com/ruby-grape/grape-entity) and check out your copy.
9
9
 
10
10
  ```
11
11
  git clone https://github.com/contributor/grape-entity.git
12
12
  cd grape-entity
13
- git remote add upstream https://github.com/intridea/grape-entity.git
13
+ git remote add upstream https://github.com/ruby-grape/grape-entity.git
14
14
  ```
15
15
 
16
16
  #### Create a Topic Branch
@@ -95,7 +95,7 @@ git push origin my-feature-branch -f
95
95
  Update the [CHANGELOG](CHANGELOG.md) with the pull request number. A typical entry looks as follows.
96
96
 
97
97
  ```
98
- * [#123](https://github.com/intridea/grape-entity/pull/123): Reticulated splines - [@contributor](https://github.com/contributor).
98
+ * [#123](https://github.com/ruby-grape/grape-entity/pull/123): Reticulated splines - [@contributor](https://github.com/contributor).
99
99
  ```
100
100
 
101
101
  Amend your previous commit and force push the changes.
data/README.md CHANGED
@@ -1,13 +1,13 @@
1
1
  # Grape::Entity
2
2
 
3
3
  [![Gem Version](http://img.shields.io/gem/v/grape-entity.svg)](http://badge.fury.io/rb/grape-entity)
4
- [![Build Status](http://img.shields.io/travis/intridea/grape-entity.svg)](https://travis-ci.org/intridea/grape-entity)
5
- [![Dependency Status](https://gemnasium.com/intridea/grape-entity.svg)](https://gemnasium.com/intridea/grape-entity)
6
- [![Code Climate](https://codeclimate.com/github/intridea/grape-entity.svg)](https://codeclimate.com/github/intridea/grape-entity)
4
+ [![Build Status](http://img.shields.io/travis/ruby-grape/grape-entity.svg)](https://travis-ci.org/ruby-grape/grape-entity)
5
+ [![Dependency Status](https://gemnasium.com/ruby-grape/grape-entity.svg)](https://gemnasium.com/ruby-grape/grape-entity)
6
+ [![Code Climate](https://codeclimate.com/github/ruby-grape/grape-entity.svg)](https://codeclimate.com/github/ruby-grape/grape-entity)
7
7
 
8
8
  ## Introduction
9
9
 
10
- This gem adds Entity support to API frameworks, such as [Grape](https://github.com/intridea/grape). Grape's Entity is an API focused facade that sits on top of an object model.
10
+ This gem adds Entity support to API frameworks, such as [Grape](https://github.com/ruby-grape/grape). Grape's Entity is an API focused facade that sits on top of an object model.
11
11
 
12
12
  ### Example
13
13
 
data/RELEASING.md CHANGED
@@ -12,7 +12,7 @@ bundle install
12
12
  rake
13
13
  ```
14
14
 
15
- Check that the last build succeeded in [Travis CI](https://travis-ci.org/intridea/grape-entity) for all supported platforms.
15
+ Check that the last build succeeded in [Travis CI](https://travis-ci.org/ruby-grape/grape-entity) for all supported platforms.
16
16
 
17
17
  Increment the version, modify [lib/grape-entity/version.rb](lib/grape-entity/version.rb).
18
18
 
data/grape-entity.gemspec CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.authors = ['Michael Bleigh']
9
9
  s.email = ['michael@intridea.com']
10
- s.homepage = 'https://github.com/intridea/grape-entity'
10
+ s.homepage = 'https://github.com/ruby-grape/grape-entity'
11
11
  s.summary = 'A simple facade for managing the relationship between your model and API.'
12
12
  s.description = 'Extracted from Grape, A Ruby framework for rapid API development with great conventions.'
13
13
  s.license = 'MIT'
@@ -112,12 +112,18 @@ module Grape
112
112
  attr_accessor :nested_exposures
113
113
  end
114
114
 
115
+ @exposures = {}
116
+ @root_exposures = {}
117
+ @nested_exposures = {}
118
+ @nested_attribute_names = {}
119
+ @formatters = {}
120
+
115
121
  def self.inherited(subclass)
116
- subclass.exposures = exposures.try(:dup) || {}
117
- subclass.root_exposures = root_exposures.try(:dup) || {}
118
- subclass.nested_exposures = nested_exposures.try(:dup) || {}
119
- subclass.nested_attribute_names = nested_attribute_names.try(:dup) || {}
120
- subclass.formatters = formatters.try(:dup) || {}
122
+ subclass.exposures = exposures.dup
123
+ subclass.root_exposures = root_exposures.dup
124
+ subclass.nested_exposures = nested_exposures.dup
125
+ subclass.nested_attribute_names = nested_attribute_names.dup
126
+ subclass.formatters = formatters.dup
121
127
  end
122
128
 
123
129
  # This method is the primary means by which you will declare what attributes
@@ -183,7 +189,10 @@ module Grape
183
189
  end
184
190
 
185
191
  def self.unexpose(attribute)
192
+ root_exposures.delete(attribute)
186
193
  exposures.delete(attribute)
194
+ nested_exposures.delete(attribute)
195
+ nested_attribute_names.delete(attribute)
187
196
  end
188
197
 
189
198
  # Set options that will be applied to any exposures declared inside the block.
@@ -1,3 +1,3 @@
1
1
  module GrapeEntity
2
- VERSION = '0.4.7'
2
+ VERSION = '0.4.8'
3
3
  end
@@ -278,6 +278,26 @@ describe Grape::Entity do
278
278
  subject.expose(:size, format_with: :size_formatter)
279
279
  expect(subject.represent(object).send(:value_for, :size)).to eq object.class.to_s
280
280
  end
281
+
282
+ it 'works global on Grape::Entity' do
283
+ Grape::Entity.format_with :size_formatter do |_date|
284
+ self.object.class.to_s
285
+ end
286
+ object = {}
287
+
288
+ subject.expose(:size, format_with: :size_formatter)
289
+ expect(subject.represent(object).send(:value_for, :size)).to eq object.class.to_s
290
+ end
291
+ end
292
+
293
+ it 'works global on Grape::Entity' do
294
+ Grape::Entity.expose :a
295
+ object = { a: 11, b: 22 }
296
+ expect(Grape::Entity.represent(object).send(:value_for, :a)).to eq 11
297
+ subject.expose :b
298
+ expect(subject.represent(object).send(:value_for, :a)).to eq 11
299
+ expect(subject.represent(object).send(:value_for, :b)).to eq 22
300
+ Grape::Entity.unexpose :a
281
301
  end
282
302
  end
283
303
 
@@ -310,6 +330,13 @@ describe Grape::Entity do
310
330
  end
311
331
  end
312
332
  end
333
+
334
+ it 'works global on Grape::Entity' do
335
+ Grape::Entity.expose :a
336
+ expect(Grape::Entity.exposures).to eq(a: {})
337
+ Grape::Entity.unexpose :a
338
+ expect(Grape::Entity.exposures).to eq({})
339
+ end
313
340
  end
314
341
 
315
342
  describe '.with_options' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grape-entity
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.7
4
+ version: 0.4.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Bleigh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-03 00:00:00.000000000 Z
11
+ date: 2015-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -144,7 +144,7 @@ files:
144
144
  - lib/grape_entity/version.rb
145
145
  - spec/grape_entity/entity_spec.rb
146
146
  - spec/spec_helper.rb
147
- homepage: https://github.com/intridea/grape-entity
147
+ homepage: https://github.com/ruby-grape/grape-entity
148
148
  licenses:
149
149
  - MIT
150
150
  metadata: {}