Sha256: 45b1ba332a2875716df3ba79dc53291e59988b553da48ad0ce937caafb5332f0

Contents?: true

Size: 1.87 KB

Versions: 2

Compression:

Stored size: 1.87 KB

Contents

# frozen_string_literal: true

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

class PathArguments < Acfs::Resource
  service UserService, path: ':required_arg/users/'

  attribute :id,           :integer
  attribute :required_arg, :string
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
acfs-2.0.0 spec/support/service.rb
acfs-1.7.0 spec/support/service.rb