composable_operations 0.3.1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bb6d4feb567aaa5715d0cc18f4ce0fa9cb657f40
4
- data.tar.gz: 90adbd786dc02ad45e48ba828d0a9d6f205a4d19
3
+ metadata.gz: 97911633d5ea509cebc6b53b4e91a2c8421c4e5c
4
+ data.tar.gz: 662c859656c3eb13d791c789d3f9c01b6c8d9610
5
5
  SHA512:
6
- metadata.gz: 907056386820c76604a5cf0e9fcb99351b970b568b1fa24600a2240eaeb2a4a79db2c06fa0e3611d79a3f64591ff08e3ca3736b885f48b6fc261120a171cefdb
7
- data.tar.gz: d5213f41b0f34e2f1e601159b836ed53e3175e78420a0da6769e3523133c4463723ff79a3e6311aeb6153328b75e34875c12e43d43c892203ea0d7ad646c7a38
6
+ metadata.gz: 5c0b471dc118210b6a3d01ce044aee797fbe8ec6cdf63796e310f7238d1955ec542b6d5f7f876f5efda312d2fb7b3cc1d970c4f7f2798fcbb298a319b49c68c6
7
+ data.tar.gz: 39062f7008cc98ae5b4a060d355cf8f011f3093b94f5580a8217cb56a6bca6da3b7cedad15aa78fd31ded75d9c5f09246fce73f4680f8d6cc58672a57026f3d0
@@ -1,22 +1,19 @@
1
1
  module ComposableOperations
2
2
  class ComposedOperation < Operation
3
3
 
4
- class AutoConfiguringOperation < SimpleDelegator
4
+ class OperationFactory < SimpleDelegator
5
5
 
6
6
  def initialize(operation_class, options = {})
7
7
  super(operation_class)
8
- @__options__ = options
8
+ @_options = options
9
9
  end
10
10
 
11
- def new(input = nil, options = {})
12
- options = Hash(__options__).merge(Hash(options))
13
- __getobj__.new(input, options)
11
+ def create(context, input = nil)
12
+ new input, Hash[Hash(@_options).map do |key, value|
13
+ [key, value.kind_of?(Proc) ? context.instance_exec(&value) : value]
14
+ end]
14
15
  end
15
16
 
16
- protected
17
-
18
- attr_reader :__options__
19
-
20
17
  end
21
18
 
22
19
  class << self
@@ -26,7 +23,7 @@ module ComposableOperations
26
23
  end
27
24
 
28
25
  def use(operation, options = {})
29
- (@operations ||= []) << AutoConfiguringOperation.new(operation, options)
26
+ (@operations ||= []) << OperationFactory.new(operation, options)
30
27
  end
31
28
 
32
29
  def compose(*operations, &block)
@@ -48,9 +45,8 @@ module ComposableOperations
48
45
  protected
49
46
 
50
47
  def execute
51
- self.class.operations.inject(input) do |data, operation_and_options|
52
- operation, options = *operation_and_options
53
- operation = operation.new(data, options)
48
+ self.class.operations.inject(input) do |data, operation|
49
+ operation = operation.create(self, data)
54
50
  operation.perform
55
51
 
56
52
  if operation.failed?
@@ -1,3 +1,3 @@
1
1
  module ComposableOperations
2
- VERSION = "0.3.1"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -72,8 +72,10 @@ describe ComposableOperations::ComposedOperation do
72
72
  string_multiplier = self.string_multiplier
73
73
 
74
74
  Class.new(described_class) do
75
+ property :multiplicator, default: 3
76
+
75
77
  use string_generator
76
- use string_multiplier, separator: ' - ', multiplicator: 3
78
+ use string_multiplier, separator: ' - ', multiplicator: lambda { multiplicator }
77
79
  end.new
78
80
  end
79
81
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: composable_operations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Konstantin Tennhard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-15 00:00:00.000000000 Z
11
+ date: 2013-06-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: smart_properties