polist 0.1.1 → 0.1.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
  SHA1:
3
- metadata.gz: 553f882315c30d976b80ff25c0b94b3375cf09b2
4
- data.tar.gz: 93d2e330621e78e12d6c3e9f795ed4f96f974ce7
3
+ metadata.gz: 59530803f30806d38aad0b2b2e37762dab03e78f
4
+ data.tar.gz: 7924ccb32b0d0b7b7c3c37cf8c56ac5576fc51bc
5
5
  SHA512:
6
- metadata.gz: 68ae4882f299838b62632e67f4b66048689c99c65e871fa77ae74dacb4c5690c079ac8e15a01d836393435d91a43e20cf53c918158b9de313861874a8ebb0f93
7
- data.tar.gz: 6128535be8447deb5c5d1cb36deac5a9b3731bd1f1649a513050b5579c65a0c8a33362d372abb09946da5f525ffa99a6d4d94bfaeffe80bed310a15dc6b3e2fa
6
+ metadata.gz: 718ccf7c528203354af38782e24bb9389470c4aaceac911004bd07087159cc27bfecd7bb71d6a71937cd8e3a433fe1aeea5409c062c4c76e5d3874824cd4274b
7
+ data.tar.gz: 947b3032b594965dbbb517a106adaf3c4be08070889eb879f5f113be5c6fb359188bc87b40b350a9123ede0b0925764cfbd8378b3f07d6aab5dceda5658b0be3
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  `Polist::Service` is a simple class designed for creating service classes.
4
4
 
5
5
  ### Basic usage example
6
- ```
6
+ ```ruby
7
7
  class MyService < Polist::Service
8
8
  def call
9
9
  if params[:ok]
@@ -25,7 +25,7 @@ service.response #=> { code: :not_cool }
25
25
 
26
26
  The only parameter that is passed to the service is called `params` by default. If you want more params, feel free to define your own initializer and call the service accordingly:
27
27
 
28
- ```
28
+ ```ruby
29
29
  class MyService < Polist::Service
30
30
  def initialize(a, b, c)
31
31
  # ...
@@ -37,7 +37,7 @@ MyService.call(1, 2, 3)
37
37
 
38
38
  Unlike `.run`, `.call` will raise `Polist::Service::Failure` exception on failure:
39
39
 
40
- ```
40
+ ```ruby
41
41
  begin
42
42
  MyService.call(ok: false)
43
43
  rescue Polist::Service::Failure => error
@@ -50,7 +50,7 @@ Note that `.run` and `.call` are just shortcuts for `MyService.new(...).run` and
50
50
  ### Using Form objects
51
51
  Sometimes you want to use some kind of params parsing and/or validation, and you can do that with the help of `Polist::Service::Form` class. It uses [tainbox](https://github.com/enthrops/tainbox) gem under the hood.
52
52
 
53
- ```
53
+ ```ruby
54
54
  class MyService < Polist::Service
55
55
  class Form < Polist::Service::Form
56
56
  attribute :param1, :String
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "active_model/validations"
3
+ require "active_model"
4
4
  require "plissken"
5
5
  require "tainbox"
6
6
 
@@ -22,6 +22,10 @@ module Polist
22
22
 
23
23
  attr_accessor :params
24
24
 
25
+ def self.build(*args)
26
+ new(*args)
27
+ end
28
+
25
29
  def self.call(*args)
26
30
  build(*args).tap(&:call)
27
31
  end
@@ -36,7 +40,7 @@ module Polist
36
40
  end
37
41
  end
38
42
 
39
- def initialize(params)
43
+ def initialize(params = {})
40
44
  self.params = params
41
45
  end
42
46
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Polist
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
@@ -25,4 +25,6 @@ Gem::Specification.new do |spec|
25
25
  spec.add_development_dependency "bundler", "~> 1.15"
26
26
  spec.add_development_dependency "rake", "~> 10.0"
27
27
  spec.add_development_dependency "rspec", "~> 3.0"
28
+ spec.add_development_dependency "pry"
29
+ spec.add_development_dependency "simplecov"
28
30
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: polist
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuri Smirnov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-05 00:00:00.000000000 Z
11
+ date: 2017-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tainbox
@@ -94,6 +94,34 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '3.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: pry
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: simplecov
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
97
125
  description: Polist is a gem for creating simple service classes.
98
126
  email:
99
127
  - tycooon@yandex.ru