roda-endpoints 0.3.3 → 0.3.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4e63ead2c011c6f56649e0e2b415888e59c3da9b
4
- data.tar.gz: 1103b4c76e38b565eea322ad02f7e1eda7e0ca90
3
+ metadata.gz: ef92cddbc54803e6fae07283c145e72db5231397
4
+ data.tar.gz: f434332c7108844d01fb5ef6e79702ae945ceec5
5
5
  SHA512:
6
- metadata.gz: 4a5d7d870f36259ffc222e569c8c4b96e71c0107675fdcc0f1912a9ddc82973d96e395e77193c2e60ca29c5233078147907aa86b7b955e57d43521d677e919f1
7
- data.tar.gz: c76f5fead6207851a7b0c312f2cefcede79fdda9c258c51567e691073d442b37d190db52b1faebee8fba9d2cb06367cc118f6335d629dd20a8b82f6da2df6dfe
6
+ metadata.gz: e815f82b5ee74d36e8eb27372b5cca397d215e4696d709f4e70d73478a1f2847d81e87b39c779e0a20563efec36828a5c2541af04b32cb560a109ba0c9920dbc
7
+ data.tar.gz: 47831e5d124a7d33a41ed06926d5b25d9faff4b2ffcaea93053a7865ec88b07582a8aa01b9403132e1fec8bb7191a80f3773bae539e3f721026315d0bc859e19
data/.rubocop.yml CHANGED
@@ -17,11 +17,14 @@ Metrics/ModuleLength:
17
17
  Exclude:
18
18
  - lib/roda/plugins/endpoints.rb
19
19
 
20
+ Metrics/ParameterLists:
21
+ Exclude:
22
+ - lib/roda/plugins/endpoints.rb
23
+
20
24
  # It is 2017, UTF time!
21
25
  Style/AsciiComments:
22
26
  Enabled: false
23
27
 
24
-
25
28
  # Offense count: 1
26
29
  Lint/AmbiguousOperator:
27
30
  Exclude:
@@ -47,7 +47,9 @@ class Roda
47
47
 
48
48
  # @return [Symbol]
49
49
  def type
50
- @type ||= Inflecto.underscore(Inflecto.demodulize(name)).to_sym
50
+ @type ||= Inflecto.underscore(Inflecto.demodulize(
51
+ name || superclass.name
52
+ )).to_sym
51
53
  end
52
54
 
53
55
  # @param [Symbol] verb
@@ -68,7 +70,7 @@ class Roda
68
70
  end
69
71
  define_method(verb, &block)
70
72
  key = "operations.#{type}.#{verb}"
71
- container.register key, block
73
+ container.register key, block unless container.key? key
72
74
  end
73
75
 
74
76
  # @param [String, Symbol] key
@@ -16,14 +16,10 @@ class Roda
16
16
  self.attributes += %i(finder last_modified)
17
17
  self.defaults = defaults.merge(
18
18
  last_modified: :updated_at,
19
- by: :fetch,
20
19
  on: :id,
21
- finder: -> { repository.public_send(by, id) }
20
+ finder: -> { repository.find(id) }
22
21
  )
23
22
 
24
- # @return [Symbol]
25
- attr_reader :by
26
-
27
23
  # @return [Symbol]
28
24
  attr_reader :on
29
25
 
@@ -59,26 +55,6 @@ class Roda
59
55
  end
60
56
  end
61
57
 
62
- transaction :get do |endpoint|
63
- step :retrieve, with: endpoint.operation_for(:get)
64
- end
65
-
66
- transaction :patch do |endpoint|
67
- step :validate, with: endpoint.validation_for(:patch)
68
- step :persist, with: endpoint.operation_for(:patch)
69
- end
70
-
71
- transaction :put do |endpoint|
72
- step :validate, with: endpoint.validation_for(:put)
73
- # step :reset, with: 'endpoints.operations.reset'
74
- step :persist, with: endpoint.operation_for(:put)
75
- end
76
-
77
- transaction :delete do |endpoint|
78
- step :validate, with: endpoint.validation_for(:delete)
79
- step :persist, with: endpoint.operation_for(:delete)
80
- end
81
-
82
58
  # @route GET /{collection.name}/{id}
83
59
  # @!method get(params)
84
60
  # @param [Hash] params
@@ -118,6 +94,26 @@ class Roda
118
94
  Left(result)
119
95
  end
120
96
  end
97
+
98
+ transaction :get do |endpoint|
99
+ step :retrieve, with: endpoint.operation_for(:get)
100
+ end
101
+
102
+ transaction :patch do |endpoint|
103
+ step :validate, with: endpoint.validation_for(:patch)
104
+ step :persist, with: endpoint.operation_for(:patch)
105
+ end
106
+
107
+ transaction :put do |endpoint|
108
+ step :validate, with: endpoint.validation_for(:put)
109
+ # step :reset, with: 'endpoints.operations.reset'
110
+ step :persist, with: endpoint.operation_for(:put)
111
+ end
112
+
113
+ transaction :delete do |endpoint|
114
+ step :validate, with: endpoint.validation_for(:delete)
115
+ step :persist, with: endpoint.operation_for(:delete)
116
+ end
121
117
  end
122
118
  end
123
119
  end
@@ -18,7 +18,7 @@ class Roda
18
18
 
19
19
  # @param [Integer] id
20
20
  # @return [ROM::Struct]
21
- def fetch(id)
21
+ def find(id)
22
22
  if id.to_i < 1
23
23
  raise ArgumentError,
24
24
  "#{self.class}#fetch: invalid id provided: #{id.inspect}"
@@ -2,6 +2,6 @@
2
2
 
3
3
  class Roda
4
4
  module Endpoints
5
- VERSION = '0.3.3'
5
+ VERSION = '0.3.4'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roda-endpoints
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Semyonov