Module: EmptyEye::BaseMethods::ClassMethods
- Defined in:
- lib/empty_eye/base_methods.rb
Instance Method Summary collapse
- #descends_from_active_record? ⇒ Boolean
-
#finder_needs_type_condition? ⇒ Boolean
we dont need no freakin’ type condition the view handles this.
-
#mti_class(primary_table = nil) {|nil| ... } ⇒ Object
interface for building mti_class primary table is not necessary if the table named correctly (Bar => bars_core) OR if the class inherits a primary table simply wrap your greasy associations in this block.
-
#mti_class? ⇒ Boolean
am i a mti class? easier than making a new class type …
-
#reflect_on_multiple_associations(*assoc_types) ⇒ Object
we need this when we add new associaton types to extend with we could use the baked in version for now.
-
#shard_wrangler ⇒ Object
the class of primary shard.
Instance Method Details
#descends_from_active_record? ⇒ Boolean
50 51 52 53 54 55 56 57 58 |
# File 'lib/empty_eye/base_methods.rb', line 50 def descends_from_active_record? if superclass.abstract_class? superclass.descends_from_active_record? elsif mti_class? superclass == ActiveRecord::Base else superclass == ActiveRecord::Base || !columns_hash.include?(inheritance_column) end end |
#finder_needs_type_condition? ⇒ Boolean
we dont need no freakin’ type condition the view handles this
41 42 43 |
# File 'lib/empty_eye/base_methods.rb', line 41 def finder_needs_type_condition? !mti_class? and super end |
#mti_class(primary_table = nil) {|nil| ... } ⇒ Object
interface for building mti_class primary table is not necessary if the table named correctly (Bar => bars_core) OR if the class inherits a primary table simply wrap your greasy associations in this block
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/empty_eye/base_methods.rb', line 19 def mti_class(primary_table = nil) raise(EmptyEye::AlreadyExtended, "MTI class method already invoked") if mti_class? self.primary_key = "id" @shard_wrangler = EmptyEye::ShardWrangler.create(self, primary_table) self.table_name = @shard_wrangler.compute_view_name before_yield = reflect_on_multiple_associations(:has_one) yield nil if block_given? mti_ancestors = reflect_on_multiple_associations(:has_one) - before_yield @shard_wrangler.wrangle_shards(mti_ancestors) true end |
#mti_class? ⇒ Boolean
am i a mti class? easier than making a new class type … i tried
11 12 13 |
# File 'lib/empty_eye/base_methods.rb', line 11 def mti_class? !!@shard_wrangler end |
#reflect_on_multiple_associations(*assoc_types) ⇒ Object
we need this when we add new associaton types to extend with we could use the baked in version for now
33 34 35 36 37 |
# File 'lib/empty_eye/base_methods.rb', line 33 def reflect_on_multiple_associations(*assoc_types) assoc_types.collect do |assoc_type| reflect_on_all_associations(assoc_type) end.flatten.uniq end |
#shard_wrangler ⇒ Object
the class of primary shard
46 47 48 |
# File 'lib/empty_eye/base_methods.rb', line 46 def shard_wrangler @shard_wrangler end |