class Tataru::Representations::ResourceRepresentation

internal representation of resources

Attributes

desc[R]
name[R]
properties[R]

Public Class Methods

new(name, desc, properties) click to toggle source
# File lib/tataru/representations/resource_representation.rb, line 9
def initialize(name, desc, properties)
  @name = name
  @properties = properties
  @desc = desc
  check_late_deletability!
end

Public Instance Methods

check_late_deletability!() click to toggle source
# File lib/tataru/representations/resource_representation.rb, line 16
def check_late_deletability!
  return unless @desc.delete_at_end? && !@desc.needs_remote_id?

  raise 'must need remote id if deletes at end'
end
check_required_fields!() click to toggle source
# File lib/tataru/representations/resource_representation.rb, line 22
def check_required_fields!
  @desc.required_fields.each do |field|
    next if @properties.key? field

    raise "Required field '#{field}' not provided in '#{@name}'"
  end
end
dependencies() click to toggle source
# File lib/tataru/representations/resource_representation.rb, line 44
def dependencies
  [@name]
end
method_missing(name, *args, &block) click to toggle source
Calls superclass method
# File lib/tataru/representations/resource_representation.rb, line 38
def method_missing(name, *args, &block)
  return super unless @desc.output_fields.include? name

  OutputRepresentation.new(@name, name)
end
remote_id() click to toggle source
# File lib/tataru/representations/resource_representation.rb, line 34
def remote_id
  OutputRepresentation.new(@name, :remote_id)
end
respond_to_missing?(name, *_args) click to toggle source
# File lib/tataru/representations/resource_representation.rb, line 30
def respond_to_missing?(name, *_args)
  true if @desc.output_fields.include? name
end