Class: EmptyEye::Shard
- Inherits:
-
Object
- Object
- EmptyEye::Shard
- Defined in:
- lib/empty_eye/shard.rb
Class Method Summary collapse
-
.exclude_always ⇒ Object
exclude from view generation always.
Instance Method Summary collapse
-
#arel_table ⇒ Object
used to create view.
-
#association ⇒ Object
association that this shard will build upon.
-
#columns ⇒ Object
the table columns that will be extended in sql.
-
#foreign_key ⇒ Object
foreign key of the shard; used in view generation and database updates.
-
#initialize(association) ⇒ Shard
constructor
shard for master_class class tracks associations for database updates managed by primary shard has many of the same interfaces as primary view shard.
- #klass ⇒ Object
-
#name ⇒ Object
name of the association.
- #polymorphic_type ⇒ Object
-
#primary ⇒ Object
never the primary.
-
#table ⇒ Object
table of the shard.
-
#type_column ⇒ Object
arel column of polymorphic type field.
-
#type_value ⇒ Object
value of the polymorphic column.
Constructor Details
#initialize(association) ⇒ Shard
shard for master_class class tracks associations for database updates managed by primary shard has many of the same interfaces as primary view shard
8 9 10 |
# File 'lib/empty_eye/shard.rb', line 8 def initialize(association) @association = association end |
Class Method Details
.exclude_always ⇒ Object
exclude from view generation always
13 14 15 |
# File 'lib/empty_eye/shard.rb', line 13 def self.exclude_always ['id','created_at','updated_at','deleted_at', 'type', 'mti_schema_version'] end |
Instance Method Details
#arel_table ⇒ Object
used to create view
43 44 45 46 47 48 49 |
# File 'lib/empty_eye/shard.rb', line 43 def arel_table @arel_table ||= begin t= Arel::Table.new(table) t.table_alias = alias_name if alias_name != table t end end |
#association ⇒ Object
association that this shard will build upon
18 19 20 |
# File 'lib/empty_eye/shard.rb', line 18 def association @association end |
#columns ⇒ Object
the table columns that will be extended in sql
23 24 25 |
# File 'lib/empty_eye/shard.rb', line 23 def columns restrictions - exclude end |
#foreign_key ⇒ Object
foreign key of the shard; used in view generation and database updates
52 53 54 |
# File 'lib/empty_eye/shard.rb', line 52 def foreign_key association.foreign_key end |
#klass ⇒ Object
56 57 58 |
# File 'lib/empty_eye/shard.rb', line 56 def klass association.klass end |
#name ⇒ Object
name of the association
38 39 40 |
# File 'lib/empty_eye/shard.rb', line 38 def name association.name end |
#polymorphic_type ⇒ Object
70 71 72 73 |
# File 'lib/empty_eye/shard.rb', line 70 def polymorphic_type return unless association.[:as] "#{association.[:as]}_type" end |
#primary ⇒ Object
never the primary
28 29 30 |
# File 'lib/empty_eye/shard.rb', line 28 def primary false end |
#table ⇒ Object
table of the shard
33 34 35 |
# File 'lib/empty_eye/shard.rb', line 33 def table association.table_name end |
#type_column ⇒ Object
arel column of polymorphic type field
61 62 63 |
# File 'lib/empty_eye/shard.rb', line 61 def type_column arel_table[polymorphic_type.to_sym] if polymorphic_type end |
#type_value ⇒ Object
value of the polymorphic column
66 67 68 |
# File 'lib/empty_eye/shard.rb', line 66 def type_value master_class.base_class.name if polymorphic_type end |