yuba 0.0.5 → 0.0.6

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: 7d13a7bddc245ba124ce105b6827afb261d6268a417809a6bc7ec04e70cff0b9
4
- data.tar.gz: c4769bdc11c239e2c99d848ab99f9b13309c5f6c4064b53b52b4087c025eeaa8
3
+ metadata.gz: 017f6300c8cb0d9867119b0e186af6d285b385abec945a23f7745648e140d709
4
+ data.tar.gz: 5c67a6522565be8935e10413298640755037ed516d30105a53bb1d1bfbf30da7
5
5
  SHA512:
6
- metadata.gz: 8337d0d4addebc3bd44412fd23d4433ebb6f17d53db5e63dcfe666b4dda6351de39450f9d48ef7fc225d62871b52d90082cefac7e6b705b38b185c1c2e9c7733
7
- data.tar.gz: 77447d91b1a2d68dd7cbf44055188d5e2bb6ac45b3b8e17af5101b0ce04952f7c4accb25f394eca3e8ba4a5b51690faba9978c45619a42603a265a19acd3c040
6
+ metadata.gz: 34d21d868256f97cf550ff18a6adb20c6ed2a46c923979ef933966c13b79503835b9db16c4df86c7cb327506dcf240c72e437bc9541e9f8548d086e6dfa58e09
7
+ data.tar.gz: 14579a01e26e0916eb2a199ed0fc182d6902130b9ad5e9cacf35700bfd1f085d0ab4d8652bbf71bedfdd108ac97d13a43f2c71ac315c07c5acd82fb9eb466e5b
data/README.md CHANGED
@@ -35,8 +35,8 @@ $ bundle install
35
35
 
36
36
  ## Support
37
37
 
38
- - Rails 4.2+
39
- - Ruby 2.2+
38
+ - Rails 5.2+
39
+ - Ruby 2.5+
40
40
 
41
41
  ## ViewModel
42
42
 
@@ -154,6 +154,17 @@ end
154
154
  - `.call` invokes `#call` after assigning arguments as properties.
155
155
  - `#success?` returns `true` if you don't invoke `#fail!`
156
156
 
157
+ You have inspection methods for properties.
158
+
159
+ ```ruby
160
+ service = CreatePostService.new(user: someuser)
161
+ service.has_property?(:user) #=> true
162
+ service.has_public_property?(:user) #=> true
163
+ service.has_private_property?(:user) #=> false
164
+ service.has_required_property?(:user) #=> true
165
+ service.has_optional_property?(:user) #=> false
166
+ ```
167
+
157
168
  ## Form
158
169
 
159
170
  Form is just wrapper of [reform-rails](https://github.com/trailblazer/reform-rails) for now.
data/lib/yuba/service.rb CHANGED
@@ -37,6 +37,26 @@ module Yuba
37
37
  !@_success
38
38
  end
39
39
 
40
+ def has_property?(property)
41
+ _properties.has_key?(property.to_sym)
42
+ end
43
+
44
+ def has_required_property?(property)
45
+ has_property?(property) && !_properties.dig(property.to_sym, :optional)
46
+ end
47
+
48
+ def has_optional_property?(property)
49
+ has_property?(property) && !has_required_property?(property)
50
+ end
51
+
52
+ def has_public_property?(property)
53
+ has_property?(property) && !has_private_property?(property)
54
+ end
55
+
56
+ def has_private_property?(property)
57
+ has_property?(property) && !_properties.dig(property.to_sym, :public)
58
+ end
59
+
40
60
  private
41
61
 
42
62
  def validate_arguments(args)
data/lib/yuba/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Yuba
2
- VERSION = '0.0.5'
2
+ VERSION = '0.0.6'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yuba
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - willnet
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-29 00:00:00.000000000 Z
11
+ date: 2021-04-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -179,7 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
179
179
  - !ruby/object:Gem::Version
180
180
  version: '0'
181
181
  requirements: []
182
- rubygems_version: 3.1.2
182
+ rubygems_version: 3.1.6
183
183
  signing_key:
184
184
  specification_version: 4
185
185
  summary: Add New Layers to Rails