Sha256: b5867c1f0c451bdcb59e9566fdb680df6b1caea6c6cda51cd06af80ca5da7630

Contents?: true

Size: 841 Bytes

Versions: 4

Compression:

Stored size: 841 Bytes

Contents

class UsersBinder < Bowline::Collection    
  class << self
    # self.items is a special method
    # Basically it'll update users on the client side
    def index
      self.items = User.all
    end
    
    # def index(offset)
    #   self.items = User.all(:conditions => ['id > ?', offset])
    # end
 
    def admins
      self.items = User.admins.all
    end
  end
  
  def update(attrs)
    if @item.update_attributes(attrs)
      flash[:notice] = "Successfully updated"
    else
      flash[:notice] = "Errors updating users"
    end
  end
 
  def highlight
    # Calls $('user_1').highlight()
    self.element.highlight
  end
  
  # Overrides charge on user
  def charge!
    # calls charge! on model (i.e. do sql commit )
    self.item.charge!
    # Now gui stuff
    flash[:notice] = "Successfully charged"
    highlight
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
maccman-bowline-0.1.1 examples/users_binder.rb
maccman-bowline-0.1.2 examples/users_binder.rb
maccman-bowline-0.1.3 examples/users_binder.rb
maccman-bowline-0.1.4 examples/users_binder.rb