cabot 0.2.1 → 0.2.2

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
  SHA256:
3
- metadata.gz: acb8ff6a08e3ca3e8744cb1f00ab8490f718649ade10f19353c60206cb1250b7
4
- data.tar.gz: 21dcf3ab26e1bc8d30baec6db4705b8e65814b5e3043af2fdda5c2c35b1691de
3
+ metadata.gz: f455209b968d12124b27e5e84cef331c64e1a84581e7b63be73bff7779164202
4
+ data.tar.gz: 4dab5fab1c23f069dc76ecc8723b593638b1a10e5c958a50f28f1f3378cb14f5
5
5
  SHA512:
6
- metadata.gz: b84336c1109699d06e2eaed190b935f8c1138820db706db11f7bcd02ab1dfdafd4752c06943268adaf6dd3ec7d06d4419ad3cb078a24fcb5d2474dde512f6161
7
- data.tar.gz: c4528fb46ba31e500a81960dd62c279e002b66628a7ae7535926a2c1d7c14182ac954d86c607350df2831ec5855b13f542bcac6ec69689de54efe7b014cb3b55
6
+ metadata.gz: 7802f90ada08ea528a0f95f118585efea5603f41612018c359e51d51b5732a8d4b7b23ac3da4e5bf460acc11b471bd410da398aa93df319476dc49e2eaec052c
7
+ data.tar.gz: 1befc8cc6ef0683caf110db4ed69003007b2f75698b4e2e4837700acf38f6b200f195171cecf129cb8bcfd3161ef4cc6aef50507e45ab1f67cb7d67775307c94
@@ -0,0 +1,57 @@
1
+ require_relative 'cabot/configuration'
2
+ require_relative 'cabot/factory'
3
+
4
+ # Cabot Gem Definition (CGD)
5
+ module Cabot
6
+ # GET
7
+ module Index
8
+ def self.call(model, current_user = {}, options = {})
9
+ object = model.to_s.camelize.constantize
10
+ params = Cabot::Parameters::Index.send(model)
11
+ options.each do |key, value|
12
+ params[key] = value
13
+ end
14
+
15
+ Factory.new(object::Index.(params, current_user: current_user))
16
+ end
17
+ end
18
+
19
+ # GET /:id
20
+ module Show
21
+ def self.call(model, current_user = {}, options = {})
22
+ object = model.to_s.camelize.constantize
23
+ params = Cabot::Parameters::Show.send(model)
24
+ options.each do |key, value|
25
+ params[key] = value
26
+ end
27
+
28
+ Factory.new(object::Show.(params, current_user: current_user))
29
+ end
30
+ end
31
+
32
+ # POST
33
+ module Create
34
+ def self.call(model, current_user = {}, options = {})
35
+ object = model.to_s.camelize.constantize
36
+ params = Cabot::Parameters::Create.send(model)
37
+ options.each do |key, value|
38
+ params[key] = value
39
+ end
40
+
41
+ Factory.new(object::Create.(params, current_user: current_user))
42
+ end
43
+ end
44
+
45
+ # PUT
46
+ module Update
47
+ def self.call(model, current_user = {}, options = {})
48
+ object = model.to_s.camelize.constantize
49
+ params = Cabot::Parameters::Update.send(model)
50
+ options.each do |key, value|
51
+ params[key] = value
52
+ end
53
+
54
+ Factory.new(object::Update.(params, current_user: current_user))
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,29 @@
1
+ # Cabot Gem Definition (CGD)
2
+ module Cabot
3
+ class << self
4
+ attr_accessor :configuration
5
+ end
6
+
7
+ def self.configuration
8
+ @configuration ||= Configuration.new
9
+ end
10
+
11
+ def self.reset
12
+ @configuration = Configuration.new
13
+ end
14
+
15
+ def self.configure
16
+ yield(configuration)
17
+ end
18
+
19
+ #
20
+
21
+ # Cabot Configuration Class (CCC)
22
+ class Configuration
23
+ attr_accessor :symbolize_keys
24
+
25
+ def initialize
26
+ @symbolize_keys = true
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,11 @@
1
+ module Cabot
2
+ class Factory
3
+ attr_accessor :result, :model, :serializer
4
+
5
+ def initialize(result)
6
+ @result = result
7
+ @model = result[Cabot.configuration.symbolize_keys ? :model : "model"]
8
+ @serializer = result[Cabot.configuration.symbolize_keys ? :serializer : "serializer"]
9
+ end
10
+ end
11
+ end
File without changes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cabot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexandre Ovcharov
@@ -17,7 +17,11 @@ email: thedoctorwhoovesmail@gmail.com
17
17
  executables: []
18
18
  extensions: []
19
19
  extra_rdoc_files: []
20
- files: []
20
+ files:
21
+ - lib/cabot.rb
22
+ - lib/cabot/configuration.rb
23
+ - lib/cabot/factory.rb
24
+ - lib/cabot/parameters.rb
21
25
  homepage: http://github.com/sheff3rd/cabot
22
26
  licenses:
23
27
  - MIT