Sha256: 13a4be43fd074f1a7a855f3598c488edbd92f65b2c3cfb9bbaf2c7d4bb777aab

Contents?: true

Size: 771 Bytes

Versions: 15

Compression:

Stored size: 771 Bytes

Contents

module Acfs::Model

  # Included by Acfs::Model. Allows a model to belong to a service.
  #
  module Service
    extend ActiveSupport::Concern

    module ClassMethods

      # Link to service this model belongs to. Connection settings like base URL
      # are fetched from service. Return assigned service if no arguments are given.
      #
      # Example
      #   class AccountService < Acfs::Client
      #     self.base_url = 'http://acc.serv.org'
      #   end
      #
      #   class MyUser
      #     service AccountService
      #   end
      #   MyUser.find 5 # Will fetch `http://acc.serv.org/users/5`
      #
      def service(klass = nil, options = {})
        return @service unless klass
        @service = klass.new options
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
acfs-0.16.0 lib/acfs/model/service.rb
acfs-0.15.0 lib/acfs/model/service.rb
acfs-0.14.0 lib/acfs/model/service.rb
acfs-0.13.0 lib/acfs/model/service.rb
acfs-0.12.0 lib/acfs/model/service.rb
acfs-0.11.0 lib/acfs/model/service.rb
acfs-0.10.0 lib/acfs/model/service.rb
acfs-0.9.0 lib/acfs/model/service.rb
acfs-0.8.0 lib/acfs/model/service.rb
acfs-0.7.0 lib/acfs/model/service.rb
acfs-0.6.0 lib/acfs/model/service.rb
acfs-0.5.1 lib/acfs/model/service.rb
acfs-0.5.0 lib/acfs/model/service.rb
acfs-0.4.0 lib/acfs/model/service.rb
acfs-0.3.0 lib/acfs/model/service.rb