module ModelManage::Mongoid::ClassMethods

Public Instance Methods

base_class() click to toggle source
# File lib/model_manage/mongoid_rails_erd.rb, line 46
def base_class
  class_of_active_record_descendant(self)
end
belongs_to(name, options = {}) click to toggle source
Calls superclass method
# File lib/model_manage/mongoid.rb, line 30
def belongs_to(name, options = {})
  super
  relation_form_set name, options
  forms.delete("#{name}_id")
end
class_of_active_record_descendant(klass) click to toggle source
# File lib/model_manage/mongoid_rails_erd.rb, line 50
def class_of_active_record_descendant(klass)
  if not Rails.models.member? klass.superclass
    klass
  else
    class_of_active_record_descendant(klass.superclass)
  end
end
column_for_attribute(attribute_name) click to toggle source
# File lib/model_manage/form.rb, line 4
def column_for_attribute(attribute_name)
  self.class.forms[attribute_name.to_s]
end
columns() click to toggle source
# File lib/model_manage/mongoid_rails_erd.rb, line 29
def columns
  forms.values
end
columns_hash() click to toggle source
# File lib/model_manage/mongoid_rails_erd.rb, line 33
def columns_hash
  forms
end
content_columns() click to toggle source
# File lib/model_manage/form.rb, line 8
def content_columns
  forms.values
end
descends_from_active_record?() click to toggle source
# File lib/model_manage/mongoid_rails_erd.rb, line 37
def descends_from_active_record?
  Rails.child_models.member? self
end
embedded_in(name, options = {}) click to toggle source
Calls superclass method
# File lib/model_manage/mongoid.rb, line 52
def embedded_in(name, options = {})
  super
  relation_form_set name, options
  forms.delete("#{name}_id")
end
embeds_many(name, options = {}) click to toggle source
Calls superclass method
# File lib/model_manage/mongoid.rb, line 57
def embeds_many(name, options = {})
  super
  relation_form_set name, options
  forms.delete("#{name.to_s.singularize}_ids")
end
has_and_belongs_to_many(name, options = {}) click to toggle source
Calls superclass method
# File lib/model_manage/mongoid.rb, line 63
def has_and_belongs_to_many(name, options = {})
  super
  relation_form_set name, options
  forms.delete("#{name.to_s.singularize}_ids")
end
has_many(name, options = {}) click to toggle source
Calls superclass method
# File lib/model_manage/mongoid.rb, line 41
def has_many(name, options = {})
  super
  relation_form_set name, options
  forms.delete("#{name.to_s.singularize}_ids")
end
inheritance_column() click to toggle source
# File lib/model_manage/mongoid_rails_erd.rb, line 25
def inheritance_column
  '_type'
end
key(* keys) click to toggle source
Calls superclass method
# File lib/model_manage/mongoid.rb, line 26
def key(* keys)
  const_set :KEYS, keys.map(&:to_s)
  super
end
referenced_in(name, options = {}) click to toggle source
Calls superclass method
# File lib/model_manage/mongoid.rb, line 35
def referenced_in(name, options = {})
  super
  relation_form_set name, options
  forms.delete("#{name}_id")
end
references_and_referenced_in_many(name, options = {}) click to toggle source
Calls superclass method
# File lib/model_manage/mongoid.rb, line 68
def references_and_referenced_in_many(name, options = {})
  super
  relation_form_set name, options
  forms.delete("#{name.to_s.singularize}_ids")
end
references_many(name, options = {}) click to toggle source
Calls superclass method
# File lib/model_manage/mongoid.rb, line 46
def references_many(name, options = {})
  super
  relation_form_set name, options
  forms.delete("#{name.to_s.singularize}_ids")
end
reflect_on_all_associations(macro = nil) click to toggle source
# File lib/model_manage/mongoid_rails_erd.rb, line 41
def reflect_on_all_associations(macro = nil)
  association_reflections = relations.values
  macro ? relations.select { |reflection| reflection.macro == macro } : association_reflections
end
reflections() click to toggle source
# File lib/model_manage/form.rb, line 12
def reflections
  relations
end