class ActiveFedora::Reflection::MacroReflection

Attributes

active_fedora[R]
name[R]

Returns the name of the macro.

has_many :clients returns :clients

options[R]

Returns the hash of options used for the macro.

has_many :clients returns +{}+

scope[R]

Public Class Methods

new(name, scope, options, active_fedora) click to toggle source

rubocop:disable Lint/MissingSuper

# File lib/active_fedora/reflection.rb, line 215
def initialize(name, scope, options, active_fedora)
  @name = name
  @scope = scope
  @options = options
  @active_fedora = active_fedora
  @klass         = options[:anonymous_class]
  @automatic_inverse_of = nil
end

Public Instance Methods

==(other) click to toggle source

Returns true if self and other_aggregation have the same name attribute, active_record attribute, and other_aggregation has an options hash assigned to it.

Calls superclass method
# File lib/active_fedora/reflection.rb, line 245
def ==(other)
  super ||
    other.is_a?(self.class) &&
      name == other.name &&
      !other.options.nil? &&
      active_record == other.active_record
end
autosave=(autosave) click to toggle source

rubocop:enable Lint/MissingSuper

# File lib/active_fedora/reflection.rb, line 225
def autosave=(autosave)
  @options[:autosave] = autosave
  parent_reflection = self.parent_reflection
  parent_reflection.autosave = autosave if parent_reflection
end
compute_class(name) click to toggle source
# File lib/active_fedora/reflection.rb, line 239
def compute_class(name)
  name.constantize
end
klass() click to toggle source

Returns the class for the macro.

composed_of :balance, class_name: 'Money' returns the Money class has_many :clients returns the Client class

# File lib/active_fedora/reflection.rb, line 235
def klass
  @klass ||= compute_class(class_name)
end

Private Instance Methods

derive_class_name() click to toggle source
# File lib/active_fedora/reflection.rb, line 255
def derive_class_name
  class_name = name.to_s.camelize
  class_name = class_name.singularize if collection?
  class_name
end