module Mongoo::Attributes::ClassMethods

Public Instance Methods

attributes() click to toggle source
# File lib/mongoo/attributes.rb, line 5
def attributes
  if @attributes
    @attributes
  else
    @attributes = {}
  end
end
attributes_tree(tree_opts={}) click to toggle source
# File lib/mongoo/attributes.rb, line 13
def attributes_tree(tree_opts={})
  tree = {}
  self.attributes.each do |name, opts|
    unless tree_opts[:only_definable] == true && opts[:define_methods] == false
      parts = name.split(".")
      curr_branch = tree
      while part = parts.shift
        if !parts.empty?
          curr_branch[part.to_s] ||= {}
          curr_branch = curr_branch[part.to_s]
        else
          curr_branch[part.to_s] = opts[:type]
        end
      end
    end # unless
  end # self.attributes
  tree
end
known_attribute?(k) click to toggle source
# File lib/mongoo/attributes.rb, line 32
def known_attribute?(k)
  k == "_id" || self.attributes[k.to_s]
end