Sha256: 278b0068e2d1beea3ae69a4901dbba9a89f8a8cccf11e28864ed9cb8a030c3ae

Contents?: true

Size: 1.54 KB

Versions: 17

Compression:

Stored size: 1.54 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 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

  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

# DRAFT: Singular resource
#class Singular < Acfs::Resource
#  service UserService, singular: true
#
#  attribute :name, :string
#end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
acfs-0.30.0.1.b260 spec/support/service.rb
acfs-0.30.0 spec/support/service.rb
acfs-0.29.1.1.b259 spec/support/service.rb
acfs-0.29.1.1.b257 spec/support/service.rb
acfs-0.29.1 spec/support/service.rb
acfs-0.29.0.1.b256 spec/support/service.rb
acfs-0.29.0.1.b254 spec/support/service.rb
acfs-0.29.0 spec/support/service.rb
acfs-0.28.0.1.b253 spec/support/service.rb
acfs-0.28.0.1.b249 spec/support/service.rb
acfs-0.28.0 spec/support/service.rb
acfs-0.27.0.1.b248 spec/support/service.rb
acfs-0.27.0.1.b244 spec/support/service.rb
acfs-0.27.0 spec/support/service.rb
acfs-0.26.0.1.b243 spec/support/service.rb
acfs-0.26.0.1.b242 spec/support/service.rb
acfs-0.26.0 spec/support/service.rb