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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: edbbe2ec6a7781533a75f61ce984fb298ee950b102e74c63cc0ec070e11d88ab
4
- data.tar.gz: b3ffeb57bd29db9c672ca5a91245de36ba4a141a8b9eb94eef0582413449032b
3
+ metadata.gz: 9f4945827359c35e199f0ca797d380b1c72f9acd7d34f228c9d652f61b823abb
4
+ data.tar.gz: c6fde36ee42649546d3edb6ac54e60f1bf1b05d2412b79ed37dcb7b4f8c3cd1e
5
5
  SHA512:
6
- metadata.gz: ed7eb1962cb354ffbb301fa1baa27ad3ec7621e5250493187953c8c69c6b5fe84f5e36ad6b6c017f4f67ab8b9ed4c6c28220f357d6ef9f2e839723c4b3bb7946
7
- data.tar.gz: 1f79dc76d225cc3ac3c1074d20685ff86d4a5da90fcd3fca79e4079235ae0b9bb78dbadda39b31a83f1800133985b8945b119162da520492198718bd9c765e09
6
+ metadata.gz: da8eaaa6e7dfd9aaa7f8ba8300d9a5c92aa1b370c3caaaad64e8497059958359fa4b02a9a981a521cd4d6841ebef9409d25be5e252e976346796f58e462d24fd
7
+ data.tar.gz: 7363de6a8c646636aa81668082c6a2fbdd16af551f7227f0d67f5db71b6ab774b056982c2ac8377e24d534c9df94fc1988e064c47fe7ffbeb0d0a7dd1446e903
@@ -0,0 +1,7 @@
1
+ # Changelog
2
+
3
+ ## 0.1.1
4
+ - if Ensurance gem is present, allow `ensure` option on `required`
5
+
6
+ ## 0.1.0
7
+ - Initial version
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/[USERNAME]/light_service_object.
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
 
@@ -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
 
@@ -1,3 +1,3 @@
1
1
  module LightServiceObject
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
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.0
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-17 00:00:00.000000000 Z
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