class DatastaxRails::Reflection::MacroReflection

Abstract base class for AggregateReflection and AssociationReflection. Objects of AggregateReflection and AssociationReflection are returned by the Reflection::ClassMethods.

Attributes

datastax_rails[R]
denorms[R]

Returns a hash of all the denormalizations for this relationship (if any)

macro[R]

Returns the macro type.

composed_of :balance, :class_name => 'Money' returns :composed_of has_many :clients returns :has_many

name[R]

Returns the name of the macro.

composed_of :balance, :class_name => 'Money' returns :balance has_many :clients returns :clients

options[R]

Returns the hash of options used for the macro.

composed_of :balance, :class_name => 'Money' returns { :class_name => "Money" } has_many :clients returns +{}+

Public Class Methods

new(macro, name, options, datastax_rails) click to toggle source
# File lib/datastax_rails/reflection.rb, line 87
def initialize(macro, name, options, datastax_rails)
  @macro           = macro
  @name            = name
  @options         = options
  @datastax_rails  = datastax_rails
  @plural_name     = name.to_s.pluralize
end

Public Instance Methods

==(other) click to toggle source

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

Calls superclass method
# File lib/datastax_rails/reflection.rb, line 113
def ==(other)
  super ||
    other.is_a?(self.class) &&
      name == other.name &&
      other.options &&
      datastax_rails == other.datastax_rails
end
class_name() click to toggle source

Returns the class name for the macro.

composed_of :balance, :class_name => 'Money' returns 'Money' has_many :clients returns 'Client'

# File lib/datastax_rails/reflection.rb, line 107
def class_name
  @class_name ||= (options[:class_name] || derive_class_name).to_s
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/datastax_rails/reflection.rb, line 99
def klass
  @klass ||= class_name.constantize
end

Private Instance Methods

derive_class_name() click to toggle source
# File lib/datastax_rails/reflection.rb, line 128
def derive_class_name
  name.to_s.camelize
end