Module Her::Model::ORM::ClassMethods
In: lib/her/model/orm.rb

Methods

Public Instance methods

Build a new resource with the given attributes. If the request_new_object_on_build flag is set, the new object is requested via API.

Define the default scope for the model

@example

  class User
    include Her::Model

    default_scope lambda { where(:admin => 1) }
  enc

  User.all # Called via GET "/users?admin=1"
  User.new.admin # => 1

Destroy an existing resource

@example

  User.destroy_existing(1)
  # Called via DELETE "/users/1"

Return or change the HTTP method used to create or update records

@param [Symbol, String] action The behavior in question (`:create` or `:update`) @param [Symbol, String] method The HTTP method to use (`’PUT’`, `:post`, etc.)

Save an existing resource and return it

@example

  @user = User.save_existing(1, { :fullname => "Tobias Fünke" })
  # Called via PUT "/users/1"

Create a new chainable scope

@example

  class User
    include Her::Model

    scope :admins, lambda { where(:admin => 1) }
    scope :page, lambda { |page| where(:page => page) }
  enc

  User.admins # Called via GET "/users?admin=1"
  User.page(2).all # Called via GET "/users?page=2"

@private

[Validate]