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.
76 77 78 |
# File 'lib/json-rpc-objects/v11/wd/service-procedure-description.rb', line 76 def idempotent @idempotent end |
#name ⇒ Symbol
Holds procedure name.
52 53 54 |
# File 'lib/json-rpc-objects/v11/wd/service-procedure-description.rb', line 52 def name @name end |
#params ⇒ Array
Holds procedure params specification.
84 85 86 |
# File 'lib/json-rpc-objects/v11/wd/service-procedure-description.rb', line 84 def params @params end |
#return ⇒ Class
Holds procedure return value specification.
92 93 94 |
# File 'lib/json-rpc-objects/v11/wd/service-procedure-description.rb', line 92 def return @return end |
#summary ⇒ String
Holds procedure summary.
60 61 62 |
# File 'lib/json-rpc-objects/v11/wd/service-procedure-description.rb', line 60 def summary @summary end |
#url ⇒ Addressable::URI
Holds procedure help URL.
68 69 70 |
# File 'lib/json-rpc-objects/v11/wd/service-procedure-description.rb', line 68 def url @url end |
Class Method Details
.create(name, opts = { }) ⇒ V11:ServiceProcedureDescription
Creates new one.
103 104 105 106 107 |
# File 'lib/json-rpc-objects/v11/wd/service-procedure-description.rb', line 103 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.
182 183 184 185 186 187 188 189 190 191 192 |
# File 'lib/json-rpc-objects/v11/wd/service-procedure-description.rb', line 182 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.
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 140 141 |
# File 'lib/json-rpc-objects/v11/wd/service-procedure-description.rb', line 113 def check! self.normalize! if not @name.symbol? raise Exception::new("Procedure name must be Symbol or convertable to Symbol.") end if not @params.nil? if (not @params.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.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 @idempotent.boolean?) raise Exception::new("If idempotent is defined, must be boolean.") end end |
#output ⇒ Hash
Renders data to output hash.
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/json-rpc-objects/v11/wd/service-procedure-description.rb', line 148 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 |