Class: Cequel::Model::ClassInternals
- Inherits:
-
Object
- Object
- Cequel::Model::ClassInternals
- Defined in:
- lib/cequel/model/class_internals.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#associations ⇒ Object
readonly
Returns the value of attribute associations.
-
#columns ⇒ Object
readonly
Returns the value of attribute columns.
-
#current_scope ⇒ Object
Returns the value of attribute current_scope.
-
#default_scope ⇒ Object
Returns the value of attribute default_scope.
-
#index_preference ⇒ Object
readonly
Returns the value of attribute index_preference.
-
#key ⇒ Object
Returns the value of attribute key.
Instance Method Summary collapse
- #add_column(name, type, options = {}) ⇒ Object
- #association(name) ⇒ Object
- #base_class ⇒ Object
- #column_family_name ⇒ Object
-
#initialize(clazz) ⇒ ClassInternals
constructor
A new instance of ClassInternals.
- #synchronize(&block) ⇒ Object
- #type_column ⇒ Object
Constructor Details
#initialize(clazz) ⇒ ClassInternals
Returns a new instance of ClassInternals.
13 14 15 16 17 18 |
# File 'lib/cequel/model/class_internals.rb', line 13 def initialize(clazz) @clazz = clazz @columns, @associations = {}, {} @index_preference = [] @lock = Monitor.new end |
Instance Attribute Details
#associations ⇒ Object (readonly)
Returns the value of attribute associations.
11 12 13 |
# File 'lib/cequel/model/class_internals.rb', line 11 def associations @associations end |
#columns ⇒ Object (readonly)
Returns the value of attribute columns.
11 12 13 |
# File 'lib/cequel/model/class_internals.rb', line 11 def columns @columns end |
#current_scope ⇒ Object
Returns the value of attribute current_scope.
10 11 12 |
# File 'lib/cequel/model/class_internals.rb', line 10 def current_scope @current_scope end |
#default_scope ⇒ Object
Returns the value of attribute default_scope.
10 11 12 |
# File 'lib/cequel/model/class_internals.rb', line 10 def default_scope @default_scope end |
#index_preference ⇒ Object (readonly)
Returns the value of attribute index_preference.
11 12 13 |
# File 'lib/cequel/model/class_internals.rb', line 11 def index_preference @index_preference end |
#key ⇒ Object
Returns the value of attribute key.
10 11 12 |
# File 'lib/cequel/model/class_internals.rb', line 10 def key @key end |
Instance Method Details
#add_column(name, type, options = {}) ⇒ Object
20 21 22 |
# File 'lib/cequel/model/class_internals.rb', line 20 def add_column(name, type, = {}) @columns[name] = Column.new(name, type, ) end |
#association(name) ⇒ Object
36 37 38 |
# File 'lib/cequel/model/class_internals.rb', line 36 def association(name) associations[name] end |
#base_class ⇒ Object
32 33 34 |
# File 'lib/cequel/model/class_internals.rb', line 32 def base_class @clazz end |
#column_family_name ⇒ Object
28 29 30 |
# File 'lib/cequel/model/class_internals.rb', line 28 def column_family_name @column_family_name ||= @clazz.name.tableize end |
#synchronize(&block) ⇒ Object
40 41 42 |
# File 'lib/cequel/model/class_internals.rb', line 40 def synchronize(&block) @lock.synchronize(&block) end |
#type_column ⇒ Object
24 25 26 |
# File 'lib/cequel/model/class_internals.rb', line 24 def type_column @columns[:class_name] end |