roda-endpoints 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/roda/endpoints/endpoint/class_interface.rb +1 -0
- data/lib/roda/endpoints/endpoint/data.rb +3 -1
- data/lib/roda/endpoints/endpoint/item.rb +6 -1
- data/lib/roda/endpoints/endpoint/singleton.rb +1 -0
- data/lib/roda/endpoints/endpoint.rb +1 -1
- data/lib/roda/endpoints/transactions.rb +3 -1
- data/lib/roda/endpoints/version.rb +1 -1
- data/lib/roda/plugins/endpoints.rb +2 -4
- data/rakelib/bundler.rake +2 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c4c0a8fcc37a1cbc7990da886c1222bac0409c40
|
4
|
+
data.tar.gz: 05d751cf1cbb8ee521d75e31a74d4fbcd431c8b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97d1319b4411dae6b2b2e8b3945e5931d8c66f1b287eded402807dd35432038db8ba1b0d6ef13dcd5f943596e1d1334d95571a71ddcfc191fa754dd866366332
|
7
|
+
data.tar.gz: '05785933922272fb8d9bec0e39e73358be4472bc4a09434ca8923b5ddc0122984c4ae6b5ffb04f09af3845c17059f6cbdc7230d9a2739de90773573a0ad985e3'
|
@@ -9,7 +9,9 @@ class Roda
|
|
9
9
|
# @param name [String]
|
10
10
|
# @param repository [String]
|
11
11
|
# @param attributes [{Symbol=>Object}]
|
12
|
-
def initialize(name:,
|
12
|
+
def initialize(name:,
|
13
|
+
repository: "repositories.#{Inflecto.pluralize(name)}",
|
14
|
+
**attributes)
|
13
15
|
@repository_key = repository
|
14
16
|
super(name: name, **attributes)
|
15
17
|
end
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'roda/endpoints/endpoint/singleton'
|
4
4
|
require 'roda/endpoints/endpoint/data'
|
5
|
+
require 'forwardable'
|
5
6
|
|
6
7
|
class Roda
|
7
8
|
module Endpoints
|
@@ -9,6 +10,8 @@ class Roda
|
|
9
10
|
# HTTP endpoint representing a specific item of collection uniquely
|
10
11
|
# identified by some parameter.
|
11
12
|
class Item < Singleton
|
13
|
+
extend Forwardable
|
14
|
+
|
12
15
|
prepend Data
|
13
16
|
|
14
17
|
self.attributes += %i(id by on)
|
@@ -23,13 +26,15 @@ class Roda
|
|
23
26
|
|
24
27
|
# @return [Integer]
|
25
28
|
def id
|
26
|
-
captures.first
|
29
|
+
@id ||= captures.first
|
27
30
|
end
|
28
31
|
|
29
32
|
# @return [Endpoint::Collection]
|
30
33
|
def collection
|
31
34
|
parent
|
32
35
|
end
|
36
|
+
|
37
|
+
def_delegator :collection, :repository
|
33
38
|
end
|
34
39
|
end
|
35
40
|
end
|
@@ -35,7 +35,7 @@ class Roda
|
|
35
35
|
# @param attributes [{Symbol=>Object}]
|
36
36
|
def initialize(**attributes)
|
37
37
|
self.class.defaults.merge(attributes).each do |key, value|
|
38
|
-
|
38
|
+
singleton_class.define_attribute(key) unless respond_to?(key)
|
39
39
|
instance_variable_set(:"@#{key}", value)
|
40
40
|
end
|
41
41
|
end
|
@@ -48,8 +48,10 @@ class Roda
|
|
48
48
|
# @param [Symbol] shortcut
|
49
49
|
# @param [Proc] block
|
50
50
|
def define(shortcut, &block)
|
51
|
+
key = key_for(shortcut)
|
52
|
+
return if container.key? key
|
51
53
|
container.register(
|
52
|
-
|
54
|
+
key,
|
53
55
|
Dry.Transaction(
|
54
56
|
container: container,
|
55
57
|
endpoint: endpoint,
|
@@ -56,7 +56,6 @@ class Roda
|
|
56
56
|
end
|
57
57
|
|
58
58
|
# `Roda::RodaRequest` instant extensions.
|
59
|
-
# rubocop:disable Metrics/ModuleLength
|
60
59
|
module RequestMethods
|
61
60
|
# Implements collection endpoint using given args
|
62
61
|
#
|
@@ -152,9 +151,8 @@ class Roda
|
|
152
151
|
|
153
152
|
# @overload singleton(name, entity, type:, **kwargs)
|
154
153
|
# @overload singleton(name:, entity:, type:, **kwargs)
|
155
|
-
def singleton(*args,
|
156
|
-
|
157
|
-
entity: args.last,
|
154
|
+
def singleton(name, *args,
|
155
|
+
entity: args.first,
|
158
156
|
type: Roda::Endpoints::Endpoint::Singleton,
|
159
157
|
**kwargs)
|
160
158
|
endpoint(
|
data/rakelib/bundler.rake
CHANGED