business_process 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/business_process/base.rb +54 -0
- data/lib/business_process/version.rb +3 -0
- data/lib/business_process.rb +1 -0
- metadata +60 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 42233ddf7c0eec955525558b26bbc00a77dbaa2d
|
4
|
+
data.tar.gz: a59df790bfb781939132c7ef884efe08be31a31d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e43ea3f9984cd415b881bdb9a14082d5908ff9e5656f9f086954ccee1a567af2779a16c1d4ca1cf9a773ab56b775076eba03007a2bf5fe30c3040c978ea15d67
|
7
|
+
data.tar.gz: 03774ef4933aeafede5b0b0f1958b4335018dddc55309b0180ab6560c930ab193c424a05f353ae0cf35cc0efa36451cc4a1e556249a176843da9e48390292ff2
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module BusinessProcess
|
2
|
+
class Base
|
3
|
+
class << self
|
4
|
+
attr_accessor :requirements
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.call(parameter_object, options={})
|
8
|
+
new(parameter_object, options).tap do |business_process|
|
9
|
+
business_process.instance_eval do
|
10
|
+
self.result = call
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.needs(field)
|
16
|
+
self.requirements ||= []
|
17
|
+
self.requirements << field
|
18
|
+
|
19
|
+
define_method field do
|
20
|
+
if parameter_object.is_a?(Hash) && parameter_object.has_key?(field)
|
21
|
+
parameter_object[field]
|
22
|
+
elsif parameter_object.respond_to?(field)
|
23
|
+
parameter_object.public_send(field)
|
24
|
+
else
|
25
|
+
raise NoMethodError, "Missing method: #{field.inspect} for the parameter object called for class: #{self.class.name}"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def initialize(parameter_object, options = {})
|
31
|
+
@parameter_object = parameter_object
|
32
|
+
@options = options
|
33
|
+
end
|
34
|
+
|
35
|
+
attr_accessor :result
|
36
|
+
attr_reader :parameter_object, :options
|
37
|
+
private :result=, :parameter_object, :options
|
38
|
+
|
39
|
+
# Defaults to the boolean'ed result of "call"
|
40
|
+
def success?
|
41
|
+
!!result
|
42
|
+
end
|
43
|
+
|
44
|
+
# Checks if parameter object responds to all methods that process needs
|
45
|
+
def valid?
|
46
|
+
self.class.requirements.all? { |required_method| parameter_object.respond_to?(required_method) }
|
47
|
+
end
|
48
|
+
|
49
|
+
# Business process
|
50
|
+
def call
|
51
|
+
raise NoMethodError, "Called undefined #call. You need to implement the method in the class: #{self.class.name}"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'business_process/base'
|
metadata
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: business_process
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- stevo
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-06-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description: General purpose service object abstraction
|
28
|
+
email:
|
29
|
+
- blazejek@gmail.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- lib/business_process.rb
|
35
|
+
- lib/business_process/base.rb
|
36
|
+
- lib/business_process/version.rb
|
37
|
+
homepage: https://github.com/Selleo/business_process
|
38
|
+
licenses: []
|
39
|
+
metadata: {}
|
40
|
+
post_install_message:
|
41
|
+
rdoc_options: []
|
42
|
+
require_paths:
|
43
|
+
- lib
|
44
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
requirements: []
|
55
|
+
rubyforge_project: "[none]"
|
56
|
+
rubygems_version: 2.2.2
|
57
|
+
signing_key:
|
58
|
+
specification_version: 4
|
59
|
+
summary: General purpose service object abstraction
|
60
|
+
test_files: []
|