Class: Skip

Inherits:
Dry::Struct
  • Object
show all
Defined in:
lib/schema.rb

Overview

Whether this step should be skipped. Passing a string provides a reason for skipping this command

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_dynamic!(d) ⇒ Object



1080
1081
1082
1083
1084
1085
# File 'lib/schema.rb', line 1080

def self.from_dynamic!(d)
  return new(bool: d, string: nil) if schema[:bool].right.valid? d
  return new(string: d, bool: nil) if schema[:string].right.valid? d

  raise "Invalid union"
end

.from_json!(json) ⇒ Object



1087
1088
1089
# File 'lib/schema.rb', line 1087

def self.from_json!(json)
  from_dynamic!(JSON.parse(json))
end

Instance Method Details

#to_dynamicObject



1091
1092
1093
1094
1095
1096
1097
# File 'lib/schema.rb', line 1091

def to_dynamic
  if !bool.nil?
    bool
  elsif !string.nil?
    string
  end
end

#to_json(options = nil) ⇒ Object



1099
1100
1101
# File 'lib/schema.rb', line 1099

def to_json(options = nil)
  JSON.generate(to_dynamic, options)
end