class DatastaxRails::Reflection::MacroReflection
Abstract base class for AggregateReflection and AssociationReflection
. Objects of AggregateReflection and AssociationReflection
are returned by the Reflection::ClassMethods
.
Attributes
Returns a hash of all the denormalizations for this relationship (if any)
Returns the macro type.
composed_of :balance, :class_name => 'Money'
returns :composed_of
has_many :clients
returns :has_many
Returns the name of the macro.
composed_of :balance, :class_name => 'Money'
returns :balance
has_many :clients
returns :clients
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
# 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
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.
# 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
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
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
# File lib/datastax_rails/reflection.rb, line 128 def derive_class_name name.to_s.camelize end