class Integrative::Integration

Attributes

call_options[RW]
init_options[RW]
integrated_class[RW]
integrator_class[RW]
name[RW]

Public Class Methods

new(name, integrator_class, options) click to toggle source
# File lib/integrative/integration.rb, line 9
def initialize(name, integrator_class, options)
  @name = name
  @integrator_class = integrator_class
  @integrated_class = name.to_s.camelize.singularize.constantize
  @init_options = options
end

Public Instance Methods

integrated_key() click to toggle source
# File lib/integrative/integration.rb, line 47
def integrated_key
  default_integrated_key = "#{integrator_class.name.underscore}_id"
  init_options[:integrated_key] || default_integrated_key
end
integrator_key() click to toggle source
# File lib/integrative/integration.rb, line 43
def integrator_key
  init_options[:integrator_key] || :id
end
invalidate() click to toggle source
# File lib/integrative/integration.rb, line 16
def invalidate
  if call_options.blank? && init_options[:requires].present?
    raise Errors::RuntimeOptionMissingError.new(self)
  end

  if call_options.present? && init_options[:requires].blank?
    raise Errors::UnexpectedRuntimeOptionError.new(self)
  end

  if call_options.present? && init_options[:requires].present?
    unexpected_options = call_options.keys - init_options[:requires]
    missing_options = init_options[:requires] - call_options.keys

    if unexpected_options.present?
      raise Errors::TooManyRuntimeOptionsError.new(self, unexpected_options)
    end

    if missing_options.present?
      raise Errors::TooLittleRuntimeOptionsError.new(self, missing_options)
    end
  end
end
setter() click to toggle source
# File lib/integrative/integration.rb, line 39
def setter
  "#{name}="
end