Class: OCI::Psql::Models::PatchMoveInstruction

Inherits:
PatchInstruction show all
Defined in:
lib/oci/psql/models/patch_move_instruction.rb

Overview

An operation that "puts" values from elsewhere in the target, functionally equivalent to a single add and then a remove. The first item of the selection is replaced, or created if the selection is empty. NOT_FOUND exceptions in the selection are handled by creating the implied containing structure. This operation fails if the from selection yields any exceptions, or if an item is moved to any of its descendants.

Constant Summary collapse

POSITION_ENUM =
[
  POSITION_AT = 'AT'.freeze,
  POSITION_BEFORE = 'BEFORE'.freeze,
  POSITION_AFTER = 'AFTER'.freeze
].freeze

Constants inherited from PatchInstruction

OCI::Psql::Models::PatchInstruction::OPERATION_ENUM

Instance Attribute Summary collapse

Attributes inherited from PatchInstruction

#operation, #selection

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from PatchInstruction

get_subtype

Constructor Details

#initialize(attributes = {}) ⇒ PatchMoveInstruction

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash

Options Hash (attributes):

  • :selection (String)

    The value to assign to the #selection proprety

  • :from (String)

    The value to assign to the #from property

  • :position (String)

    The value to assign to the #position property



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/oci/psql/models/patch_move_instruction.rb', line 66

def initialize(attributes = {})
  return unless attributes.is_a?(Hash)

  attributes['operation'] = 'MOVE'

  super(attributes)

  # convert string to symbol for hash key
  attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }

  self.from = attributes[:'from'] if attributes[:'from']

  self.position = attributes[:'position'] if attributes[:'position']
  self.position = "AT" if position.nil? && !attributes.key?(:'position') # rubocop:disable Style/StringLiterals
end

Instance Attribute Details

#fromString

[Required] The selection that is to be moved, with the same format and semantics as selection.

Returns:

  • (String)


24
25
26
# File 'lib/oci/psql/models/patch_move_instruction.rb', line 24

def from
  @from
end

#positionString

Where to insert the value in an array, relative to the first item in the selection. If there is no such item, then "BEFORE" specifies insertion at the first position in an array and "AFTER" specifies insertion at the last position. If the first item in the selection is not the child of an array, then this field has no effect.

Returns:

  • (String)


31
32
33
# File 'lib/oci/psql/models/patch_move_instruction.rb', line 31

def position
  @position
end

Class Method Details

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



34
35
36
37
38
39
40
41
42
43
# File 'lib/oci/psql/models/patch_move_instruction.rb', line 34

def self.attribute_map
  {
    # rubocop:disable Style/SymbolLiteral
    'operation': :'operation',
    'selection': :'selection',
    'from': :'from',
    'position': :'position'
    # rubocop:enable Style/SymbolLiteral
  }
end

.swagger_typesObject

Attribute type mapping.



46
47
48
49
50
51
52
53
54
55
# File 'lib/oci/psql/models/patch_move_instruction.rb', line 46

def self.swagger_types
  {
    # rubocop:disable Style/SymbolLiteral
    'operation': :'String',
    'selection': :'String',
    'from': :'String',
    'position': :'String'
    # rubocop:enable Style/SymbolLiteral
  }
end

Instance Method Details

#==(other) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • other (Object)

    the other object to be compared



97
98
99
100
101
102
103
104
105
# File 'lib/oci/psql/models/patch_move_instruction.rb', line 97

def ==(other)
  return true if equal?(other)

  self.class == other.class &&
    operation == other.operation &&
    selection == other.selection &&
    from == other.from &&
    position == other.position
end

#build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# File 'lib/oci/psql/models/patch_move_instruction.rb', line 130

def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)

  self.class.swagger_types.each_pair do |key, type|
    if type =~ /^Array<(.*)>/i
      # check to ensure the input is an array given that the the attribute
      # is documented as an array but the input is not
      if attributes[self.class.attribute_map[key]].is_a?(Array)
        public_method("#{key}=").call(
          attributes[self.class.attribute_map[key]]
            .map { |v| OCI::Internal::Util.convert_to_type(Regexp.last_match(1), v) }
        )
      end
    elsif !attributes[self.class.attribute_map[key]].nil?
      public_method("#{key}=").call(
        OCI::Internal::Util.convert_to_type(type, attributes[self.class.attribute_map[key]])
      )
    end
    # or else data not found in attributes(hash), not an issue as the data can be optional
  end

  self
end

#eql?(other) ⇒ Boolean

Parameters:

  • other (Object)

    the other object to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


110
111
112
# File 'lib/oci/psql/models/patch_move_instruction.rb', line 110

def eql?(other)
  self == other
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



119
120
121
# File 'lib/oci/psql/models/patch_move_instruction.rb', line 119

def hash
  [operation, selection, from, position].hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



163
164
165
166
167
168
169
170
171
172
# File 'lib/oci/psql/models/patch_move_instruction.rb', line 163

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = public_method(attr).call
    next if value.nil? && !instance_variable_defined?("@#{attr}")

    hash[param] = _to_hash(value)
  end
  hash
end

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



157
158
159
# File 'lib/oci/psql/models/patch_move_instruction.rb', line 157

def to_s
  to_hash.to_s
end