Module: LiveResource::Resource

Includes:
Attributes, Declarations, Finders, LogHelper, Methods
Defined in:
lib/live_resource/resource.rb

Overview

Module for all Resource providers. Any instances of resources should be registered with LiveResource::register. The class may also be registered, if any class attributes/methods should be remotely callable.

Instance Attribute Summary

Attributes included from Methods

#dispatcher

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Methods

#remote_methods, #running?, #start, #stop

Methods included from Attributes

#redis, #remote_attribute_modify, #remote_attribute_read, #remote_attribute_write, #remote_attribute_writenx, #remote_attributes

Methods included from Declarations

#resource_class, #resource_name

Methods included from LogHelper

#logger, #logger=

Class Method Details

.included(base) ⇒ Object

Extends resource classes with proper class methods and class-level method dispatcher.



23
24
25
26
27
28
29
30
# File 'lib/live_resource/resource.rb', line 23

def self.included(base)
  base.extend(LiveResource::Declarations::ClassMethods)

  # The class is also extended with attribute and method support
  # (i.e, the method dispatcher).
  base.extend(LiveResource::Attributes)
  base.extend(LiveResource::Methods)
end

Instance Method Details

#forward(resource, method, *params) ⇒ LiveResource::RemoteMethodForward

Create forward instruction that can be returned by a remote method, instructing LiveResource to forward to a different remote method instead of returing directly to the caller.

Parameters:

  • resource (LiveResource::ResourceProxy)

    the resource to forward to

  • method (Symbol)

    the resource’s method to call

  • params

    any parameters to pass with the method call

Returns:



40
41
42
# File 'lib/live_resource/resource.rb', line 40

def forward(resource, method, *params)
  LiveResource::RemoteMethodForward.new(resource, method, params)
end