Class: JsonRpcObjects::V11::WD::ServiceProcedureDescription
- Inherits:
-
Generic::Object
- Object
- Generic::Object
- JsonRpcObjects::V11::WD::ServiceProcedureDescription
- Defined in:
- lib/json-rpc-objects/v11/wd/service-procedure-description.rb
Overview
Description of one procedure of the service.
Direct Known Subclasses
Constant Summary collapse
- VERSION =
Holds link to its version module.
JsonRpcObjects::V11::WD
- PARAMETER_DESCRIPTION_CLASS =
Indicates the procedure parameter description class.
JsonRpcObjects::V11::WD::ProcedureParameterDescription
Instance Attribute Summary collapse
-
#idempotent ⇒ Boolean
Indicates procedure idempotency.
-
#name ⇒ Symbol
Holds procedure name.
-
#params ⇒ Array
Holds procedure params specification.
-
#return ⇒ Class
Holds procedure return value specification.
-
#summary ⇒ String
Holds procedure summary.
-
#url ⇒ Addressable::URI
Holds procedure help URL.
Attributes inherited from Generic::Object
Class Method Summary collapse
-
.create(name, opts = { }) ⇒ V11:ServiceProcedureDescription
Creates new one.
Instance Method Summary collapse
-
#<<(value) ⇒ Object
Receives service procedure description objects.
-
#check! ⇒ Object
Checks correctness of the data.
-
#output ⇒ Hash
Renders data to output hash.
Methods inherited from Generic::Object
#initialize, parse, #serialize, #to_json, version
Constructor Details
This class inherits a constructor from JsonRpcObjects::Generic::Object
Instance Attribute Details
#idempotent ⇒ Boolean
Indicates procedure idempotency.
74 75 76 |
# File 'lib/json-rpc-objects/v11/wd/service-procedure-description.rb', line 74 def idempotent @idempotent end |
#name ⇒ Symbol
Holds procedure name.
50 51 52 |
# File 'lib/json-rpc-objects/v11/wd/service-procedure-description.rb', line 50 def name @name end |
#params ⇒ Array
Holds procedure params specification.
82 83 84 |
# File 'lib/json-rpc-objects/v11/wd/service-procedure-description.rb', line 82 def params @params end |
#return ⇒ Class
Holds procedure return value specification.
90 91 92 |
# File 'lib/json-rpc-objects/v11/wd/service-procedure-description.rb', line 90 def return @return end |
#summary ⇒ String
Holds procedure summary.
58 59 60 |
# File 'lib/json-rpc-objects/v11/wd/service-procedure-description.rb', line 58 def summary @summary end |
#url ⇒ Addressable::URI
Holds procedure help URL.
66 67 68 |
# File 'lib/json-rpc-objects/v11/wd/service-procedure-description.rb', line 66 def url @url end |
Class Method Details
.create(name, opts = { }) ⇒ V11:ServiceProcedureDescription
Creates new one.
101 102 103 104 105 |
# File 'lib/json-rpc-objects/v11/wd/service-procedure-description.rb', line 101 def self.create(name, opts = { }) data = { :name => name } data.merge! opts return self::new(data) end |
Instance Method Details
#<<(value) ⇒ Object
Receives service procedure description objects.
180 181 182 183 184 185 186 187 188 189 190 |
# File 'lib/json-rpc-objects/v11/wd/service-procedure-description.rb', line 180 def <<(value) if not value.kind_of? self.class::PARAMETER_DESCRIPTION_CLASS raise Exception::new(self.class::PARAMETER_DESCRIPTION_CLASS.name.dup << " object expected.") end if @params.nil? @params = [ ] end @params << value end |
#check! ⇒ Object
Checks correctness of the data.
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/json-rpc-objects/v11/wd/service-procedure-description.rb', line 111 def check! self.normalize! if not @name.kind_of? Symbol raise Exception::new("Procedure name must be Symbol or convertable to Symbol.") end if not @params.nil? if (not @params.kind_of? Array) or (not @params.all? { |v| v.kind_of? self.class::PARAMETER_DESCRIPTION_CLASS }) raise Exception::new("If params is defined, must be an Array of " << self.class::PARAMETER_DESCRIPTION_CLASS.name << " objects.") end if @params.kind_of? Array @params.each { |param| param.check! } end end if not @return.nil? if not @return.kind_of? self.class::PARAMETER_DESCRIPTION_CLASS raise Exception::new("If return is defined, must be set to " << self.class::PARAMETER_DESCRIPTION_CLASS.name << " object.") end @return.check! end if (not @idempotent.nil?) and (not Utils::Object.boolean? @idempotent) raise Exception::new("If idempotent is defined, must be boolean.") end end |
#output ⇒ Hash
Renders data to output hash.
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/json-rpc-objects/v11/wd/service-procedure-description.rb', line 146 def output self.check! data = { "name" => @name.to_s } if not @summary.nil? data["summary"] = @summary end if not @help.nil? data["help"] = @help.to_s end if not @idempotent.nil? data["idempotent"] = @idempotent end if not @params.nil? data["params"] = @params.map { |i| i.output } end if not @return.nil? data["return"] = @return.output end return data end |