class Filemaker::Model::Relations::Proxy

A proxy is a class to send all unknown methods to it's target. The target here will be the eventual associated model.

Attributes

options[RW]
owner[RW]
target[RW]

Public Class Methods

init(owner, name, options) click to toggle source

Create will not return the proxy if target was NilClass

# File lib/filemaker/model/relations/proxy.rb, line 25
def self.init(owner, name, options)
  new_instance = new(owner, name, options)
  new_instance.target.nil? ? nil : new_instance
end
new(owner, name, options) click to toggle source

@param [Filemaker::Layout] owner The instance of the model @param [String] name The relationship name @param [Hash] options Relationship options

# File lib/filemaker/model/relations/proxy.rb, line 17
def initialize(owner, name, options)
  @owner = owner
  @name = name
  @options = options
  @class_name = options.fetch(:class_name) { name.to_s.classify }
end

Public Instance Methods

method_missing(name, *args, &block) click to toggle source

Rubocop will complain and ask to fallback on `super`, but we won't be able to do that because the target may have method that throw exception

# File lib/filemaker/model/relations/proxy.rb, line 39
def method_missing(name, *args, &block)
  target.send(name, *args, &block)
end
respond_to_missing?(method_name, include_private = false) click to toggle source
Calls superclass method
# File lib/filemaker/model/relations/proxy.rb, line 43
def respond_to_missing?(method_name, include_private = false)
  super
end
target_class() click to toggle source
# File lib/filemaker/model/relations/proxy.rb, line 30
def target_class
  return @class_name if @class_name.is_a?(Class)

  @class_name.constantize
end