Module: ActiveRemote::DSL::ClassMethods
- Defined in:
- lib/active_remote/dsl.rb
Instance Method Summary collapse
-
#attr_publishable(*attributes) ⇒ Object
Whitelist enable attributes for serialization purposes.
-
#namespace(name = false) ⇒ Object
Set the namespace for the underlying RPC service class.
-
#publishable_attributes ⇒ Object
Retrieve the attributes that have been whitelisted for serialization.
-
#service_class(klass = false) ⇒ Object
Set the RPC service class directly.
-
#service_name(name = false) ⇒ Object
Set the name of the underlying RPC service class.
Instance Method Details
#attr_publishable(*attributes) ⇒ Object
Whitelist enable attributes for serialization purposes.
Examples
# To only publish the :guid and :status attributes:
class User < ActiveRemote::Base
attr_publishable :guid, :status
end
18 19 20 21 |
# File 'lib/active_remote/dsl.rb', line 18 def attr_publishable(*attributes) @publishable_attributes ||= [] @publishable_attributes += attributes end |
#namespace(name = false) ⇒ Object
Set the namespace for the underlying RPC service class. If no namespace is given, then none will be used.
Examples
# If the user's service class is namespaced (e.g. Acme::UserService):
class User < ActiveRemote::Base
namespace :acme
end
33 34 35 36 |
# File 'lib/active_remote/dsl.rb', line 33 def namespace(name = false) @namespace = name unless name == false @namespace end |
#publishable_attributes ⇒ Object
Retrieve the attributes that have been whitelisted for serialization.
40 41 42 |
# File 'lib/active_remote/dsl.rb', line 40 def publishable_attributes @publishable_attributes end |
#service_class(klass = false) ⇒ Object
Set the RPC service class directly. By default, ActiveRemote determines the RPC service by constantizing the namespace and service name.
Examples
class User < ActiveRemote::Base
service_class Acme::UserService
end
# ...is the same as:
class User < ActiveRemote::Base
namespace :acme
service_name :user_service
end
# ...is the same as:
class User < ActiveRemote::Base
namespace :acme
end
66 67 68 69 |
# File 'lib/active_remote/dsl.rb', line 66 def service_class(klass = false) @service_class = klass unless klass == false @service_class ||= _determine_service_class end |
#service_name(name = false) ⇒ Object
Set the name of the underlying RPC service class. By default, Active Remote assumes that a User model will have a UserService (making the service name :user_service).
Examples
class User < ActiveRemote::Base
service_name :jangly_users
end
81 82 83 84 |
# File 'lib/active_remote/dsl.rb', line 81 def service_name(name = false) @service_name = name unless name == false @service_name ||= _determine_service_name end |