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.
- #endpoint_for_create(endpoint) ⇒ Object
- #endpoint_for_delete(endpoint) ⇒ Object
- #endpoint_for_destroy(endpoint) ⇒ Object
- #endpoint_for_search(endpoint) ⇒ Object
- #endpoint_for_update(endpoint) ⇒ Object
- #endpoints(endpoints_hash = nil) ⇒ Object
-
#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 |
#endpoint_for_create(endpoint) ⇒ Object
23 24 25 |
# File 'lib/active_remote/dsl.rb', line 23 def endpoint_for_create(endpoint) endpoints :create => endpoint end |
#endpoint_for_delete(endpoint) ⇒ Object
27 28 29 |
# File 'lib/active_remote/dsl.rb', line 27 def endpoint_for_delete(endpoint) endpoints :delete => endpoint end |
#endpoint_for_destroy(endpoint) ⇒ Object
31 32 33 |
# File 'lib/active_remote/dsl.rb', line 31 def endpoint_for_destroy(endpoint) endpoints :destroy => endpoint end |
#endpoint_for_search(endpoint) ⇒ Object
35 36 37 |
# File 'lib/active_remote/dsl.rb', line 35 def endpoint_for_search(endpoint) endpoints :search => endpoint end |
#endpoint_for_update(endpoint) ⇒ Object
39 40 41 |
# File 'lib/active_remote/dsl.rb', line 39 def endpoint_for_update(endpoint) endpoints :update => endpoint end |
#endpoints(endpoints_hash = nil) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/active_remote/dsl.rb', line 43 def endpoints(endpoints_hash = nil) @endpoints ||= { :create => :create, :delete => :delete, :destroy => :destroy, :search => :search, :update => :update } @endpoints.merge!(endpoints_hash) if endpoints_hash.present? @endpoints 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
65 66 67 68 |
# File 'lib/active_remote/dsl.rb', line 65 def namespace(name = false) @namespace = name unless name == false @namespace end |
#publishable_attributes ⇒ Object
Retrieve the attributes that have been whitelisted for serialization.
72 73 74 |
# File 'lib/active_remote/dsl.rb', line 72 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
98 99 100 101 |
# File 'lib/active_remote/dsl.rb', line 98 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
113 114 115 116 |
# File 'lib/active_remote/dsl.rb', line 113 def service_name(name = false) @service_name = name unless name == false @service_name ||= _determine_service_name end |