Class: MassiveRecord::ORM::Schema::ColumnFamilies
- Inherits:
-
Set
- Object
- Set
- MassiveRecord::ORM::Schema::ColumnFamilies
- Defined in:
- lib/massive_record/orm/schema/column_families.rb
Instance Method Summary collapse
- #add(family) ⇒ Object (also: #<<)
- #attribute_name_taken?(name) ⇒ Boolean
- #attribute_names ⇒ Object
- #family_by_name(name) ⇒ Object
- #family_by_name_or_new(name) ⇒ Object
- #to_hash ⇒ Object
Instance Method Details
#add(family) ⇒ Object Also known as: <<
9 10 11 12 13 |
# File 'lib/massive_record/orm/schema/column_families.rb', line 9 def add(family) family.column_families = self raise InvalidColumnFamily.new(family.errors..join(". ")) unless family.valid? super end |
#attribute_name_taken?(name) ⇒ Boolean
42 43 44 |
# File 'lib/massive_record/orm/schema/column_families.rb', line 42 def attribute_name_taken?(name) attribute_names.include? name.to_s end |
#attribute_names ⇒ Object
37 38 39 |
# File 'lib/massive_record/orm/schema/column_families.rb', line 37 def attribute_names to_hash.keys end |
#family_by_name(name) ⇒ Object
17 18 19 |
# File 'lib/massive_record/orm/schema/column_families.rb', line 17 def family_by_name(name) detect { |family| family.name == name.to_s } end |
#family_by_name_or_new(name) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/massive_record/orm/schema/column_families.rb', line 21 def family_by_name_or_new(name) unless known_family = family_by_name(name) known_family = ColumnFamily.new(:name => name) add(known_family) end known_family end |
#to_hash ⇒ Object
30 31 32 33 34 35 |
# File 'lib/massive_record/orm/schema/column_families.rb', line 30 def to_hash inject({}) do |hash, column_family| hash.update(column_family.to_hash) hash end end |