Module: ActsAsList::Mongoid::Fields
- Defined in:
- lib/mongoid/acts_as_list.rb
Instance Method Summary collapse
- #==(other) ⇒ Object
- #[](field_name) ⇒ Object
- #[]=(key, value) ⇒ Object
- #my_position ⇒ Object
- #position_key ⇒ Object
- #set_my_position(new_position) ⇒ Object
Instance Method Details
#==(other) ⇒ Object
414 415 416 417 418 |
# File 'lib/mongoid/acts_as_list.rb', line 414 def ==(other) return true if other.equal?(self) return true if other.instance_of?(self.class) and other.respond_to?('_id') and other._id == self._id false end |
#[](field_name) ⇒ Object
405 406 407 |
# File 'lib/mongoid/acts_as_list.rb', line 405 def [](field_name) self.send field_name end |
#[]=(key, value) ⇒ Object
409 410 411 412 |
# File 'lib/mongoid/acts_as_list.rb', line 409 def []=(key, value) @attributes[key.to_s] = value save! end |
#my_position ⇒ Object
394 395 396 |
# File 'lib/mongoid/acts_as_list.rb', line 394 def my_position self[position_column] end |
#position_key ⇒ Object
420 421 422 |
# File 'lib/mongoid/acts_as_list.rb', line 420 def position_key position_column.to_sym end |
#set_my_position(new_position) ⇒ Object
398 399 400 401 402 403 |
# File 'lib/mongoid/acts_as_list.rb', line 398 def set_my_position new_position if new_position != my_position self.update_attributes position_column => new_position save! end end |