light_service_object 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +2 -8
- data/lib/light_service_object.rb +20 -0
- data/lib/light_service_object/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f4945827359c35e199f0ca797d380b1c72f9acd7d34f228c9d652f61b823abb
|
4
|
+
data.tar.gz: c6fde36ee42649546d3edb6ac54e60f1bf1b05d2412b79ed37dcb7b4f8c3cd1e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da8eaaa6e7dfd9aaa7f8ba8300d9a5c92aa1b370c3caaaad64e8497059958359fa4b02a9a981a521cd4d6841ebef9409d25be5e252e976346796f58e462d24fd
|
7
|
+
data.tar.gz: 7363de6a8c646636aa81668082c6a2fbdd16af551f7227f0d67f5db71b6ab774b056982c2ac8377e24d534c9df94fc1988e064c47fe7ffbeb0d0a7dd1446e903
|
data/CHANGELOG.md
ADDED
data/README.md
CHANGED
@@ -1,14 +1,12 @@
|
|
1
1
|
# LightServiceObject
|
2
2
|
|
3
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/light_service_object`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
6
3
|
|
7
4
|
## Installation
|
8
5
|
|
9
6
|
Add this line to your application's Gemfile:
|
10
7
|
|
11
8
|
```ruby
|
9
|
+
gem 'ensurance' # Optional
|
12
10
|
gem 'light_service_object'
|
13
11
|
```
|
14
12
|
|
@@ -16,10 +14,6 @@ And then execute:
|
|
16
14
|
|
17
15
|
$ bundle
|
18
16
|
|
19
|
-
Or install it yourself as:
|
20
|
-
|
21
|
-
$ gem install light_service_object
|
22
|
-
|
23
17
|
## Usage
|
24
18
|
|
25
19
|
TODO: Write usage instructions here
|
@@ -32,7 +26,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
32
26
|
|
33
27
|
## Contributing
|
34
28
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
29
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/bsharpe/light_service_object.
|
36
30
|
|
37
31
|
## License
|
38
32
|
|
data/lib/light_service_object.rb
CHANGED
@@ -2,6 +2,26 @@ require "light_service_object/version"
|
|
2
2
|
require "dry/initializer"
|
3
3
|
require "dry/monads/result"
|
4
4
|
|
5
|
+
# frozen_string_literal: true
|
6
|
+
|
7
|
+
if defined?(Ensurance)
|
8
|
+
# Define a dispatcher for `:model` option
|
9
|
+
rails_dispatcher = ->(ensure: nil, **options) do
|
10
|
+
# NOTE: This is because 'ensure' is a reserved word in Ruby
|
11
|
+
klass = binding.local_variable_get(:ensure)
|
12
|
+
return options unless klass
|
13
|
+
|
14
|
+
klass = klass.constantize if klass.is_a?(String)
|
15
|
+
klass = klass.klass if klass.is_a?(ActiveRecord::Relation)
|
16
|
+
|
17
|
+
coercer = ->(value) { klass.ensure(value) }
|
18
|
+
options.merge(type: coercer)
|
19
|
+
end
|
20
|
+
|
21
|
+
# Register a dispatcher
|
22
|
+
Dry::Initializer::Dispatchers << rails_dispatcher
|
23
|
+
end
|
24
|
+
|
5
25
|
module LightServiceObject
|
6
26
|
class Error < StandardError; end
|
7
27
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: light_service_object
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Sharpe
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-01-
|
11
|
+
date: 2019-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -90,6 +90,7 @@ files:
|
|
90
90
|
- ".gitignore"
|
91
91
|
- ".rspec"
|
92
92
|
- ".travis.yml"
|
93
|
+
- CHANGELOG.md
|
93
94
|
- Gemfile
|
94
95
|
- LICENSE.txt
|
95
96
|
- README.md
|