Class: MassiveRecord::ORM::Schema::ColumnFamily

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Validations
Defined in:
lib/massive_record/orm/schema/column_family.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ ColumnFamily

Returns a new instance of ColumnFamily.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/massive_record/orm/schema/column_family.rb', line 21

def initialize(*args)
  options = args.extract_options!
  options.symbolize_keys!

  @fields = Fields.new
  @fields.contained_in = self

  if options.has_key? :autoload
    # TODO remove this for next version
    ActiveSupport::Deprecation.warn("autoload is deprecated as an intitializer option. Please use autoload_fields instead!")
    options[:autoload_fields] = options.delete :autoload
  end

  self.name = options[:name]
  self.column_families = options[:column_families]
  self.autoload_fields = options[:autoload_fields]
end

Instance Attribute Details

#autoload_fields=(value) ⇒ Object

Sets the attribute autoload_fields

Parameters:

  • value

    the value to set the attribute autoload_fields to.



7
8
9
# File 'lib/massive_record/orm/schema/column_family.rb', line 7

def autoload_fields=(value)
  @autoload_fields = value
end

#column_familiesObject

Returns the value of attribute column_families.



7
8
9
# File 'lib/massive_record/orm/schema/column_family.rb', line 7

def column_families
  @column_families
end

#fieldsObject (readonly)

Returns the value of attribute fields.



8
9
10
# File 'lib/massive_record/orm/schema/column_family.rb', line 8

def fields
  @fields
end

#nameObject

Returns the value of attribute name.



8
9
10
# File 'lib/massive_record/orm/schema/column_family.rb', line 8

def name
  @name
end

#options_for_autoload_created_fieldsObject (readonly)

Returns the value of attribute options_for_autoload_created_fields.



8
9
10
# File 'lib/massive_record/orm/schema/column_family.rb', line 8

def options_for_autoload_created_fields
  @options_for_autoload_created_fields
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



39
40
41
# File 'lib/massive_record/orm/schema/column_family.rb', line 39

def ==(other)
  other.instance_of?(self.class) && other.hash == hash
end

#attribute_name_taken?(name, check_only_self = false) ⇒ Boolean

Returns:

  • (Boolean)


56
57
58
59
# File 'lib/massive_record/orm/schema/column_family.rb', line 56

def attribute_name_taken?(name, check_only_self = false)
  name = name.to_s
  check_only_self || contained_in.nil? ? fields.attribute_name_taken?(name, true) : contained_in.attribute_name_taken?(name)
end

#autoload?Boolean

Returns:

  • (Boolean)


67
68
69
70
71
# File 'lib/massive_record/orm/schema/column_family.rb', line 67

def autoload?
  # TODO remove this method for next version
  ActiveSupport::Deprecation.warn("ColumnFamily#autoload? is deprecated. Please use autoload_fields? instead")
  autoload_fields?
end

#autoload_fields?Boolean

Returns:

  • (Boolean)


63
64
65
# File 'lib/massive_record/orm/schema/column_family.rb', line 63

def autoload_fields?
  @autoload_fields == true
end

#contained_inObject



52
53
54
# File 'lib/massive_record/orm/schema/column_family.rb', line 52

def contained_in
  column_families
end

#contained_in=(column_families) ⇒ Object



48
49
50
# File 'lib/massive_record/orm/schema/column_family.rb', line 48

def contained_in=(column_families)
  self.column_families = column_families
end

#hashObject



44
45
46
# File 'lib/massive_record/orm/schema/column_family.rb', line 44

def hash
  name.hash
end