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