Class: DatastaxRails::Reflection::MacroReflection
- Defined in:
- lib/datastax_rails/reflection.rb
Overview
Abstract base class for AggregateReflection and AssociationReflection. Objects of AggregateReflection and AssociationReflection are returned by the Reflection::ClassMethods.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#datastax_rails ⇒ Object
readonly
Returns the value of attribute datastax_rails.
-
#denorms ⇒ Object
readonly
Returns a hash of all the denormalizations for this relationship (if any).
-
#macro ⇒ Object
readonly
Returns the macro type.
-
#name ⇒ Object
readonly
Returns the name of the macro.
-
#options ⇒ Object
readonly
Returns the hash of options used for the macro.
-
#plural_name ⇒ Object
readonly
:nodoc:.
Instance Method Summary collapse
-
#==(other) ⇒ Object
Returns
true
ifself
andother_aggregation
have the samename
attribute,datastax_rails
attribute, andother_aggregation
has an options hash assigned to it. -
#class_name ⇒ Object
Returns the class name for the macro.
-
#initialize(macro, name, options, datastax_rails) ⇒ MacroReflection
constructor
A new instance of MacroReflection.
-
#klass ⇒ Object
Returns the class for the macro.
-
#sanitized_conditions ⇒ Object
XXX: Do we need to sanitize our query?.
Constructor Details
#initialize(macro, name, options, datastax_rails) ⇒ MacroReflection
Returns a new instance of MacroReflection.
87 88 89 90 91 92 93 |
# File 'lib/datastax_rails/reflection.rb', line 87 def initialize(macro, name, , datastax_rails) @macro = macro @name = name @options = @datastax_rails = datastax_rails @plural_name = name.to_s.pluralize end |
Instance Attribute Details
#datastax_rails ⇒ Object (readonly)
Returns the value of attribute datastax_rails.
80 81 82 |
# File 'lib/datastax_rails/reflection.rb', line 80 def datastax_rails @datastax_rails end |
#denorms ⇒ Object (readonly)
Returns a hash of all the denormalizations for this relationship (if any)
83 84 85 |
# File 'lib/datastax_rails/reflection.rb', line 83 def denorms @denorms end |
#macro ⇒ Object (readonly)
Returns the macro type.
composed_of :balance, :class_name => 'Money'
returns :composed_of
has_many :clients
returns :has_many
72 73 74 |
# File 'lib/datastax_rails/reflection.rb', line 72 def macro @macro end |
#name ⇒ Object (readonly)
Returns the name of the macro.
composed_of :balance, :class_name => 'Money'
returns :balance
has_many :clients
returns :clients
66 67 68 |
# File 'lib/datastax_rails/reflection.rb', line 66 def name @name end |
#options ⇒ Object (readonly)
Returns the hash of options used for the macro.
composed_of :balance, :class_name => 'Money'
returns { :class_name => "Money" }
has_many :clients
returns {}
78 79 80 |
# File 'lib/datastax_rails/reflection.rb', line 78 def @options end |
#plural_name ⇒ Object (readonly)
:nodoc:
85 86 87 |
# File 'lib/datastax_rails/reflection.rb', line 85 def plural_name @plural_name end |
Instance Method Details
#==(other) ⇒ Object
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.
113 114 115 116 117 118 119 |
# File 'lib/datastax_rails/reflection.rb', line 113 def ==(other) super || other.is_a?(self.class) && name == other.name && other. && datastax_rails == other.datastax_rails end |
#class_name ⇒ Object
Returns the class name for the macro.
composed_of :balance, :class_name => 'Money'
returns 'Money'
has_many :clients
returns 'Client'
107 108 109 |
# File 'lib/datastax_rails/reflection.rb', line 107 def class_name @class_name ||= ([:class_name] || derive_class_name).to_s end |
#klass ⇒ Object
Returns the class for the macro.
composed_of :balance, :class_name => 'Money'
returns the Money class has_many :clients
returns the Client class
99 100 101 |
# File 'lib/datastax_rails/reflection.rb', line 99 def klass @klass ||= class_name.constantize end |
#sanitized_conditions ⇒ Object
XXX: Do we need to sanitize our query?
122 123 124 |
# File 'lib/datastax_rails/reflection.rb', line 122 def sanitized_conditions #:nodoc: @sanitized_conditions ||= [:conditions] end |