Permalink
Browse files

Fix conflicts

  • Loading branch information...
2 parents 465d106 + c73b616 commit 60f4120c36a8ace6eeb566186e96489d10ad23c2 @shuber committed May 28, 2009
Showing with 17 additions and 9 deletions.
  1. +5 −0 CHANGELOG
  2. +11 −8 lib/sortable.rb
  3. +1 −1 sortable.gemspec
View
@@ -1,5 +1,10 @@
2009-05-27 - Sean Huber (shuber@huberry.com)
* Use self.class.base_class when scoping records
+ * Fix conflicts
+
+2009-05-14 - Sean Huber (shuber@huberry.com)
+ * Remove MIT-LICENSE from gemspec - github complaining for some reason
+ * Type cast position and offset arguments as integers
2009-05-13 - Sean Huber (shuber@huberry.com)
* Fix bug - item_at_offset method was not scoping correctly
View
@@ -182,13 +182,16 @@ def in_list?(list_name = nil)
#
# Also aliased as <tt>insert_at_position!</tt>
def insert_at!(position = 1, list_name = nil)
- remove_from_list!(list_name)
- if position > last_position(list_name)
- add_to_list!(list_name)
- else
- move_lower_items(:down, position - 1, list_name)
- send("#{evaluate_sortable_options(list_name)[:column]}=".to_sym, position)
- save
+ position = position.to_s.to_i
+ if position > 0
+ remove_from_list!(list_name)
+ if position > last_position(list_name)
+ add_to_list!(list_name)
+ else
+ move_lower_items(:down, position - 1, list_name)
+ send("#{evaluate_sortable_options(list_name)[:column]}=".to_sym, position)
+ save
+ end
end
end
alias_method :insert_at_position!, :insert_at!
@@ -204,7 +207,7 @@ def insert_at!(position = 1, list_name = nil)
# Returns nil if an item at the specified offset could not be found
def item_at_offset(offset, list_name = nil)
options = evaluate_sortable_options(list_name)
- in_list?(list_name) ? self.class.base_class.send("find_by_#{options[:column]}".to_sym, send(options[:column]) + offset, :conditions => options[:conditions]) : nil
+ in_list?(list_name) ? self.class.base_class.send("find_by_#{options[:column]}".to_sym, send(options[:column]) + offset.to_s.to_i, :conditions => options[:conditions]) : nil
end
# Returns the last item in a list associated with the current item
View
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = 'sortable'
- s.version = '1.0.2'
+ s.version = '1.0.3'
s.date = '2009-05-27'
s.summary = 'Allows you to sort ActiveRecord items in multiple lists with multiple scopes'

0 comments on commit 60f4120

Please sign in to comment.