Skip to content

Commit

Permalink
Fix conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
shuber committed May 28, 2009
2 parents 465d106 + c73b616 commit 60f4120
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG
@@ -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
Expand Down
19 changes: 11 additions & 8 deletions lib/sortable.rb
Expand Up @@ -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!
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion sortable.gemspec
@@ -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'
Expand Down

0 comments on commit 60f4120

Please sign in to comment.