Class: CassandraObject::BelongsTo::Reflection

Inherits:
Object
  • Object
show all
Defined in:
lib/cassandra_object/belongs_to/reflection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model, name, options) ⇒ Reflection

Returns a new instance of Reflection.



5
6
7
# File 'lib/cassandra_object/belongs_to/reflection.rb', line 5

def initialize(model, name, options)
  @model, @name, @options = model, name, options
end

Instance Attribute Details

#modelObject (readonly)

Returns the value of attribute model.



4
5
6
# File 'lib/cassandra_object/belongs_to/reflection.rb', line 4

def model
  @model
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/cassandra_object/belongs_to/reflection.rb', line 4

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



4
5
6
# File 'lib/cassandra_object/belongs_to/reflection.rb', line 4

def options
  @options
end

Instance Method Details

#class_nameObject



25
26
27
# File 'lib/cassandra_object/belongs_to/reflection.rb', line 25

def class_name
  options[:class_name] || name.to_s.camelize
end

#foreign_keyObject



13
14
15
# File 'lib/cassandra_object/belongs_to/reflection.rb', line 13

def foreign_key
  "#{name}_id"
end

#instance_variable_nameObject



9
10
11
# File 'lib/cassandra_object/belongs_to/reflection.rb', line 9

def instance_variable_name
  "@#{name}"
end

#polymorphic?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/cassandra_object/belongs_to/reflection.rb', line 21

def polymorphic?
  options[:polymorphic]
end

#polymorphic_columnObject



17
18
19
# File 'lib/cassandra_object/belongs_to/reflection.rb', line 17

def polymorphic_column
  "#{name}_type"
end