Module: Yogo::DataMapper::Model::Configuration

Defined in:
lib/yogo/datamapper/model/configuration.rb

Instance Method Summary collapse

Instance Method Details

#operation(op_name, *args) ⇒ Object



13
14
15
16
# File 'lib/yogo/datamapper/model/configuration.rb', line 13

def operation(op_name, *args)
  op_def = [op_name.to_s, args].flatten
  operation_definitions << op_def unless operation_definitions.include?(op_def)
end

#operation_definitionsObject



9
10
11
# File 'lib/yogo/datamapper/model/configuration.rb', line 9

def operation_definitions
  @_operation_definitions ||= []
end

#to_procObject



18
19
20
21
22
23
24
25
26
27
# File 'lib/yogo/datamapper/model/configuration.rb', line 18

def to_proc
  ops = operation_definitions.map{|op_def| Operations[op_def.first] }
  partial_ops = []
  ops.each_with_index do |op, i|
    next unless op
    partial_ops[i] = op.partial(X, *operation_definitions[i][1..-1])
  end
  partial_ops.compact!
  partial_ops.reduce{|composed, partial_op| composed * partial_op}
end