Module: MongoDoc::Attributes
- Defined in:
- lib/mongo_doc/attributes.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(klass) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/mongo_doc/attributes.rb', line 3 def self.included(klass) klass.class_eval do class_inheritable_array :_keys self._keys = [] class_inheritable_array :_associations self._associations = [] attr_accessor :_id extend ClassMethods end end |
Instance Method Details
#attributes ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/mongo_doc/attributes.rb', line 16 def attributes hash = {} self.class._attributes.each do |attr| hash[attr] = send(attr) end hash end |
#attributes=(attrs) ⇒ Object
24 25 26 27 28 |
# File 'lib/mongo_doc/attributes.rb', line 24 def attributes=(attrs) attrs.each do |key, value| send("#{key}=", value) end end |