Class: Igniter::Contracts::Contractable::Definition

Inherits:
Struct
  • Object
show all
Defined in:
lib/igniter/contracts/contractable.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method_name:, inputs: [], outputs: [], role: nil, stage: nil, metadata: {}) ⇒ Definition

Returns a new instance of Definition.



62
63
64
65
66
67
68
69
70
71
72
# File 'lib/igniter/contracts/contractable.rb', line 62

def initialize(method_name:, inputs: [], outputs: [], role: nil, stage: nil, metadata: {})
  super(
    method_name: method_name.to_sym,
    inputs: inputs.map(&:to_sym).freeze,
    outputs: outputs.map(&:to_sym).freeze,
    role: role&.to_sym,
    stage: stage&.to_sym,
    metadata: .dup.freeze
  )
  freeze
end

Instance Attribute Details

#inputsObject

Returns the value of attribute inputs

Returns:

  • (Object)

    the current value of inputs



61
62
63
# File 'lib/igniter/contracts/contractable.rb', line 61

def inputs
  @inputs
end

#metadataObject

Returns the value of attribute metadata

Returns:

  • (Object)

    the current value of metadata



61
62
63
# File 'lib/igniter/contracts/contractable.rb', line 61

def 
  @metadata
end

#method_nameObject

Returns the value of attribute method_name

Returns:

  • (Object)

    the current value of method_name



61
62
63
# File 'lib/igniter/contracts/contractable.rb', line 61

def method_name
  @method_name
end

#outputsObject

Returns the value of attribute outputs

Returns:

  • (Object)

    the current value of outputs



61
62
63
# File 'lib/igniter/contracts/contractable.rb', line 61

def outputs
  @outputs
end

#roleObject

Returns the value of attribute role

Returns:

  • (Object)

    the current value of role



61
62
63
# File 'lib/igniter/contracts/contractable.rb', line 61

def role
  @role
end

#stageObject

Returns the value of attribute stage

Returns:

  • (Object)

    the current value of stage



61
62
63
# File 'lib/igniter/contracts/contractable.rb', line 61

def stage
  @stage
end

Instance Method Details

#to_hObject



74
75
76
77
78
79
80
81
82
83
# File 'lib/igniter/contracts/contractable.rb', line 74

def to_h
  {
    method_name: method_name,
    inputs: inputs,
    outputs: outputs,
    role: role,
    stage: stage,
    metadata: .dup
  }.compact
end