Sha256: ba05920b2d861e0d9a1406965c6d7157455d5c393ae675994d058d0b30ed4370

Contents?: true

Size: 1.69 KB

Versions: 34

Compression:

Stored size: 1.69 KB

Contents

Acfs.configure do
  locate :user_service, 'http://users.example.org'
  locate :computer_service, 'http://computers.example.org'
  locate :comments, 'http://comments.example.org'
end

class UserService < Acfs::Service
  use Acfs::Middleware::MessagePackDecoder
  use Acfs::Middleware::JsonDecoder
  use Acfs::Middleware::JsonEncoder
end

class CommentService < Acfs::Service
  identity :comments

  use Acfs::Middleware::JsonDecoder
end

class MyUser < Acfs::Resource
  service UserService, path: 'users'

  attribute :id, :integer
  attribute :name, :string, default: 'Anon'
  attribute :age, :integer
end

class Profile < Acfs::SingletonResource
  service UserService, path: 'users/:user_id/profile'

  attribute :user_id, :integer
  attribute :twitter_handle, :string
end

class Customer < MyUser

end

class MyUserWithValidations < MyUser
  validates_presence_of :name, :age
  validates_format_of :name, with: /\A\w+\s+\w+.?\z/
end

class Session < Acfs::Resource
  service UserService, path: {
      list: 'users/:user_id/sessions',
      delete: 'users/:user_id/sessions/del/:id',
      update: nil
  }

  attribute :id, :string
  attribute :user, :integer
end

class Comment < Acfs::Resource
  service CommentService

  attribute :id, :integer
  attribute :text, :string
end

class ComputerService < Acfs::Service
  use Acfs::Middleware::MessagePackDecoder
  use Acfs::Middleware::JsonDecoder
  use Acfs::Middleware::JsonEncoder
end

class Computer < Acfs::Resource
  service ComputerService, path: 'computers'

  attribute :id, :integer
end

class PC < Computer

end

class Mac < Computer

end

class Single < Acfs::SingletonResource
  service UserService

  attribute :score, :integer
  attribute :user_id, :integer
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
acfs-0.39.0 spec/support/service.rb
acfs-1.0.0.dev.1.b305 spec/support/service.rb
acfs-0.38.0 spec/support/service.rb
acfs-1.0.0.dev.1.b298 spec/support/service.rb
acfs-1.0.0.dev.1.b297 spec/support/service.rb
acfs-0.37.0.1.b295 spec/support/service.rb
acfs-0.37.0 spec/support/service.rb
acfs-0.36.0.1.b293 spec/support/service.rb
acfs-0.36.0 spec/support/service.rb
acfs-0.35.0.1.b291 spec/support/service.rb
acfs-0.35.0 spec/support/service.rb
acfs-0.34.1.1.b289 spec/support/service.rb
acfs-0.34.1 spec/support/service.rb
acfs-0.34.0.1.b288 spec/support/service.rb
acfs-0.34.0.1.b287 spec/support/service.rb
acfs-0.34.0.1.b286 spec/support/service.rb
acfs-0.34.0 spec/support/service.rb
acfs-0.33.1.1.b285 spec/support/service.rb
acfs-0.33.1.1.b281 spec/support/service.rb
acfs-0.33.1 spec/support/service.rb