Class: Cequel::Model::ClassInternals

Inherits:
Object
  • Object
show all
Defined in:
lib/cequel/model/class_internals.rb

Direct Known Subclasses

SubclassInternals

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#associationsObject (readonly)

Returns the value of attribute associations.



11
12
13
# File 'lib/cequel/model/class_internals.rb', line 11

def associations
  @associations
end

#columnsObject (readonly)

Returns the value of attribute columns.



11
12
13
# File 'lib/cequel/model/class_internals.rb', line 11

def columns
  @columns
end

#current_scopeObject

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_scopeObject

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_preferenceObject (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

#keyObject

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, options = {})
  @columns[name] = Column.new(name, type, options)
end

#association(name) ⇒ Object



36
37
38
# File 'lib/cequel/model/class_internals.rb', line 36

def association(name)
  associations[name]
end

#base_classObject



32
33
34
# File 'lib/cequel/model/class_internals.rb', line 32

def base_class
  @clazz
end

#column_family_nameObject



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_columnObject



24
25
26
# File 'lib/cequel/model/class_internals.rb', line 24

def type_column
  @columns[:class_name]
end