Module: Mongoo::Attributes::ClassMethods
- Defined in:
- lib/mongoo/attributes.rb
Instance Method Summary collapse
Instance Method Details
#attributes ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/mongoo/attributes.rb', line 5 def attributes if @attributes @attributes else @attributes = {} end end |
#attributes_tree(tree_opts = {}) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# 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) ⇒ Boolean
32 33 34 |
# File 'lib/mongoo/attributes.rb', line 32 def known_attribute?(k) k == "_id" || self.attributes[k.to_s] end |