Module: Liszt::InstanceMethods
- Defined in:
- lib/liszt.rb
Class Method Summary collapse
Instance Method Summary collapse
- #add_to_list ⇒ Object
- #add_to_or_remove_from_list ⇒ Object
- #move_down! ⇒ Object
- #move_to_bottom! ⇒ Object
- #move_to_top! ⇒ Object
- #move_up! ⇒ Object
- #remove_from_list ⇒ Object
Class Method Details
.included(base) ⇒ Object
197 198 199 200 201 202 203 |
# File 'lib/liszt.rb', line 197 def self.included(base) base.class_eval do after_create :add_to_list after_update :add_to_or_remove_from_list after_destroy :remove_from_list end end |
Instance Method Details
#add_to_list ⇒ Object
205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
# File 'lib/liszt.rb', line 205 def add_to_list if ordered_list_initialized? if meets_list_conditions? if self.class.liszt_append_new_items ordered_list.push id else ordered_list.unshift id end end else initialize_list! end true end |
#add_to_or_remove_from_list ⇒ Object
220 221 222 223 224 225 226 227 |
# File 'lib/liszt.rb', line 220 def add_to_or_remove_from_list if meets_list_conditions? add_to_list else remove_from_list end true end |
#move_down! ⇒ Object
242 243 244 |
# File 'lib/liszt.rb', line 242 def move_down! ordered_list.move_down id end |
#move_to_bottom! ⇒ Object
246 247 248 |
# File 'lib/liszt.rb', line 246 def move_to_bottom! ordered_list.move_to_bottom id end |
#move_to_top! ⇒ Object
234 235 236 |
# File 'lib/liszt.rb', line 234 def move_to_top! ordered_list.move_to_top id end |
#move_up! ⇒ Object
238 239 240 |
# File 'lib/liszt.rb', line 238 def move_up! ordered_list.move_up id end |
#remove_from_list ⇒ Object
229 230 231 232 |
# File 'lib/liszt.rb', line 229 def remove_from_list ordered_list.remove id true end |