class R2OAS::Schema::V3::FromFiles::BaseRef

Attributes

parent[RW]

Public Instance Methods

[](key) click to toggle source
# File lib/r2-oas/schema/v3/object/from_files/utils/refs.rb, line 26
def [](key)
  send(key)
end
[]=(key, value) click to toggle source
# File lib/r2-oas/schema/v3/object/from_files/utils/refs.rb, line 16
def []=(key, value)
  if writable_keys.include?(key)
    send(:"#{key}=", value)
    value
  else
    display_key = key.is_a?(Symbol) ? ":#{key}" : key
    raise ::R2OAS::RefInvalidAssignment, "invalid method `[#{display_key}]=' called for #{self}"
  end
end
pretty_print(q) click to toggle source
# File lib/r2-oas/schema/v3/object/from_files/utils/refs.rb, line 10
def pretty_print(q)
  pp_hash(q, to_h)
end
to_h() click to toggle source
# File lib/r2-oas/schema/v3/object/from_files/utils/refs.rb, line 30
def to_h
  valid_keys.each_with_object({}) do |key, result|
    result[key] = send(key)
  end
end

Private Instance Methods

build(ref_or_data, merge_data = {}) click to toggle source
# File lib/r2-oas/schema/v3/object/from_files/utils/refs.rb, line 55
def build(ref_or_data, merge_data = {})
  data = ref_or_data.to_h.merge(merge_data)
  data.keys.each do |key|
    instance_variable_set(:"@#{key}", data[key])
  end

  @parent = ref_or_data if ref_or_data.respond_to?(:parent)
end
pp_hash(q, obj) click to toggle source

MEMO: apidock.com/ruby/v1_9_3_392/PP/PPMethods/pp_hash

# File lib/r2-oas/schema/v3/object/from_files/utils/refs.rb, line 40
def pp_hash(q, obj)
  q.group(1, '{', '}') do
    q.seplist(obj, nil, :each_pair) do |k, v|
      q.group do
        q.pp k
        q.text '=>'
        q.group(1) do
          q.breakable ''
          q.pp v
        end
      end
    end
  end
end
valid_keys() click to toggle source
# File lib/r2-oas/schema/v3/object/from_files/utils/refs.rb, line 66
def valid_keys
  raise NoImplementError, 'Please implement in inherited class.'
end
writable_keys() click to toggle source
# File lib/r2-oas/schema/v3/object/from_files/utils/refs.rb, line 70
def writable_keys
  raise NoImplementError, 'Please implement in inherited class.'
end