Sha256: 6a7bcb146fa9787200439046d94e2052bda40110fe38df8a8f4dcb150b83da14

Contents?: true

Size: 1.32 KB

Versions: 16

Compression:

Stored size: 1.32 KB

Contents

module Hoth
  class Services
    
    # With Hoth::Services.define followed by a block you define all your
    # available services.
    #
    # Example:
    #
    #     Hoth::Services.define do
    #       
    #       service :increment_counter do |counter|
    #         returns :nothing
    #       end
    #       
    #       service :value_of_counter do |counter|
    #         returns :fixnum
    #       end
    #       
    #       service :create_account do |account|
    #         returns :account_id
    #       end
    #       
    #     end
    #   
    # after defining your services you can call each of them with
    # <tt>Hoth::Services.service_name(params)</tt>
    #       
    #     Hoth::Services.increment_counter(counter)
    #     current_number = Hoth::Services.value_of_counter(counter)
    #     created_account = Hoth::Services.create_account(account)
    #
    # see Hoth::ServiceDefinition for further informations of the block
    # content.
    
    def self.define(&block)
      ServiceDefinition.new.instance_eval(&block)
    end
    
    class <<self

      # this is where the services get called
      def method_missing(meth, *args, &blk) # :nodoc:
        if _service = ServiceRegistry.locate_service(meth)
          _service.execute(*args)
        else
          super
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
hoth-0.4.2 lib/hoth/services.rb
hoth-0.4.1 lib/hoth/services.rb
hoth-0.4.0 lib/hoth/services.rb
hoth-0.3.4 lib/hoth/services.rb
hoth-0.3.3 lib/hoth/services.rb
hoth-0.3.2.beta4 lib/hoth/services.rb
hoth-0.3.2.beta3 lib/hoth/services.rb
hoth-0.3.2.beta2 lib/hoth/services.rb
hoth-0.3.2.beta1 lib/hoth/services.rb
hoth-0.3.1 lib/hoth/services.rb
sk-hoth-0.3.5 lib/hoth/services.rb
sk-hoth-0.3.4 lib/hoth/services.rb
sk-hoth-0.3.2 lib/hoth/services.rb
sk-hoth-0.3.1 lib/hoth/services.rb
sk-hoth-0.3.0 lib/hoth/services.rb
hoth-0.3.0 lib/hoth/services.rb