Class: RPCoder::Param
- Inherits:
-
Object
- Object
- RPCoder::Param
- Defined in:
- lib/rpcoder/param.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#options ⇒ Object
Returns the value of attribute options.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
- #array? ⇒ Boolean
- #array_or_type ⇒ Object
- #array_param ⇒ Object
- #element_accessor(elem = 'elem', options = {}) ⇒ Object
-
#initialize(name, type, options = {}) ⇒ Param
constructor
A new instance of Param.
- #instance_creator(elem = 'elem', options = {}) ⇒ Object
- #original_type? ⇒ Boolean
Constructor Details
#initialize(name, type, options = {}) ⇒ Param
Returns a new instance of Param.
8 9 10 11 12 |
# File 'lib/rpcoder/param.rb', line 8 def initialize(name, type, = {}) @name = name @type = type @options = end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'lib/rpcoder/param.rb', line 7 def name @name end |
#options ⇒ Object
Returns the value of attribute options.
7 8 9 |
# File 'lib/rpcoder/param.rb', line 7 def @options end |
#type ⇒ Object
Returns the value of attribute type.
7 8 9 |
# File 'lib/rpcoder/param.rb', line 7 def type @type end |
Class Method Details
.original_types ⇒ Object
3 4 5 |
# File 'lib/rpcoder/param.rb', line 3 def self.original_types [:int, :String, :Boolean, :Array] end |
Instance Method Details
#array? ⇒ Boolean
14 15 16 |
# File 'lib/rpcoder/param.rb', line 14 def array? [:array?] end |
#array_or_type ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/rpcoder/param.rb', line 18 def array_or_type if array? "Array" else type end end |
#array_param ⇒ Object
30 31 32 |
# File 'lib/rpcoder/param.rb', line 30 def array_param Param.new(name, [:array_type]) end |
#element_accessor(elem = 'elem', options = {}) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/rpcoder/param.rb', line 43 def element_accessor(elem = 'elem', = {}) if [:object?] "object['#{elem}']" else elem end end |
#instance_creator(elem = 'elem', options = {}) ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/rpcoder/param.rb', line 34 def instance_creator(elem = 'elem', = {}) elem = element_accessor(elem, ) if original_type? elem else "new #{type}(#{elem})" end end |
#original_type? ⇒ Boolean
26 27 28 |
# File 'lib/rpcoder/param.rb', line 26 def original_type? Param.original_types.include?(type.to_sym) end |