simple_monads 0.1.0 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/simple_monads/failure_object.rb +24 -0
- data/lib/simple_monads/success_object.rb +24 -0
- data/lib/simple_monads/version.rb +1 -1
- data/lib/simple_monads.rb +13 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b54f2145f19fa895f6951fc9e0654cb53c48eeea6cfdc6a5ecd637a1e2c49b2c
|
4
|
+
data.tar.gz: 2444529cb48f516bd4c87581bcebe6dcd67acdd7442534b423c88f74c992f3c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a4a540a28a1ffb96f8a5cb8348688b0c411f8d6780217d47f98a0b59d4d490164f4fe3d5ae2bc1c5cf9abdd7cb6b60c6092d32efccc1939d6ef8a1987a1ed93
|
7
|
+
data.tar.gz: aa48837f31b27ed918ddd37528ac6b112146682f158d0f9fb183623aba0687532ec4e93b97bb981a3bfd3069dd7657de30d5be5a783caf40ed82b9227746de6a
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SimpleMonads
|
4
|
+
# failure object
|
5
|
+
class FailureObject
|
6
|
+
attr_reader :object
|
7
|
+
|
8
|
+
def initialize(object)
|
9
|
+
@object = object
|
10
|
+
end
|
11
|
+
|
12
|
+
def failure?
|
13
|
+
true
|
14
|
+
end
|
15
|
+
|
16
|
+
def success?
|
17
|
+
false
|
18
|
+
end
|
19
|
+
|
20
|
+
def inspect
|
21
|
+
"Failure(#{object})"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SimpleMonads
|
4
|
+
# success object
|
5
|
+
class SuccessObject
|
6
|
+
attr_reader :object
|
7
|
+
|
8
|
+
def initialize(object)
|
9
|
+
@object = object
|
10
|
+
end
|
11
|
+
|
12
|
+
def failure?
|
13
|
+
false
|
14
|
+
end
|
15
|
+
|
16
|
+
def success?
|
17
|
+
true
|
18
|
+
end
|
19
|
+
|
20
|
+
def inspect
|
21
|
+
"Success(#{object})"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/simple_monads.rb
CHANGED
@@ -1,2 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'simple_monads/failure_object'
|
4
|
+
require_relative 'simple_monads/success_object'
|
5
|
+
|
6
|
+
# Main module
|
1
7
|
module SimpleMonads
|
8
|
+
def Success(object) # rubocop:disable Naming/MethodName
|
9
|
+
SuccessObject.new(object)
|
10
|
+
end
|
11
|
+
|
12
|
+
def Failure(object) # rubocop:disable Naming/MethodName
|
13
|
+
FailureObject.new(object)
|
14
|
+
end
|
2
15
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_monads
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kirill Leonov
|
@@ -10,13 +10,15 @@ bindir: bin
|
|
10
10
|
cert_chain: []
|
11
11
|
date: 2024-08-02 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description: Simple monads without
|
13
|
+
description: Simple monads without DRY dependencies
|
14
14
|
email: leonov835@yandex.ru
|
15
15
|
executables: []
|
16
16
|
extensions: []
|
17
17
|
extra_rdoc_files: []
|
18
18
|
files:
|
19
19
|
- lib/simple_monads.rb
|
20
|
+
- lib/simple_monads/failure_object.rb
|
21
|
+
- lib/simple_monads/success_object.rb
|
20
22
|
- lib/simple_monads/version.rb
|
21
23
|
homepage: https://github.com/leonovk/simple_monads
|
22
24
|
licenses:
|