Class: Dry::Facts::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/dry/facts/command.rb

Class Method Summary collapse

Class Method Details

.call(input) ⇒ Object



29
30
31
32
33
34
# File 'lib/dry/facts/command.rb', line 29

def call(input)
  input
  .yield_self {|it| _enforce_input_contract_on it }
  .yield_self {|it| _execute_with it.to_hash }
  .yield_self {|it| _enforce_output_contract_on it }
end

.define_input_contract(&block) ⇒ Object



36
37
38
39
40
41
# File 'lib/dry/facts/command.rb', line 36

def define_input_contract &block
  @input_contract =
    Class
    .new(Dry::Struct)
    .yield_self { |k| k.instance_eval(&block) if block }
end

.define_output_contract(&block) ⇒ Object



43
44
45
46
47
48
# File 'lib/dry/facts/command.rb', line 43

def define_output_contract &block
  @output_contract =
    Class
    .new(Dry::Struct)
    .yield_self { |k| k.instance_eval(&block) if block }
end

.input_contractObject



13
14
15
# File 'lib/dry/facts/command.rb', line 13

def input_contract
  @input_contract if defined?(@input_contract)
end

.input_contract=(value) ⇒ Object



17
18
19
# File 'lib/dry/facts/command.rb', line 17

def input_contract= value
  @input_contract = value
end

.output_contractObject



21
22
23
# File 'lib/dry/facts/command.rb', line 21

def output_contract
  @output_contract if defined?(@output_contract)
end

.output_contract=(value) ⇒ Object



25
26
27
# File 'lib/dry/facts/command.rb', line 25

def output_contract= value
  @output_contract = value
end