Module: Synaptic4r::Rest::ClassMethods
- Defined in:
- lib/synaptic4r/rest.rb
Overview
Constant Summary collapse
- @@method_defs =
.….….….….….….….….….….….….….….….….….….….….….….….….……
Hash.new{|h,k| h[k] = {:required => [], :optional => []}}
- @@arg_defs =
Hash.new{|h,k| h[k] = {}}
Instance Method Summary collapse
-
#arg_defs ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
-
#args ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
-
#args_all_methods(type) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
-
#banner(meth) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
-
#define_rest_arg(arg, opts) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
-
#define_rest_method(meth, args) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
-
#desc(meth) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
-
#diagnostics(meth) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
-
#emc_headers ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
-
#exclusive_rest_args(meth) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
-
#exe(meth) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
-
#has_rest_method?(meth) ⇒ Boolean
.….….….….….….….….….….….….….….….….….….….….….….….….……
-
#header_args(meth) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
-
#http_method(meth) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
-
#map_required_args(meth) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
-
#method_defs ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
-
#non_header_args(meth) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
-
#optional_rest_args(meth) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
-
#query(meth) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
-
#required_rest_args(meth) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
-
#rest_arg(arg) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
-
#rest_methods ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
-
#result_class(meth) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
-
#unary_rest_args(meth) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
Instance Method Details
#arg_defs ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
62 63 64 |
# File 'lib/synaptic4r/rest.rb', line 62 def arg_defs @@arg_defs end |
#args ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
88 89 90 |
# File 'lib/synaptic4r/rest.rb', line 88 def args method_defs end |
#args_all_methods(type) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
132 133 134 |
# File 'lib/synaptic4r/rest.rb', line 132 def args_all_methods(type) args[:all][type].inject([]){|r,a| rest_arg(a)[:header].eql?(:hide) ? r : r << a} end |
#banner(meth) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
147 148 149 |
# File 'lib/synaptic4r/rest.rb', line 147 def (meth) args[meth][:banner] end |
#define_rest_arg(arg, opts) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
83 84 85 |
# File 'lib/synaptic4r/rest.rb', line 83 def define_rest_arg(arg, opts) arg_defs[arg].update(opts) end |
#define_rest_method(meth, args) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/synaptic4r/rest.rb', line 67 def define_rest_method(meth, args) [meth].flatten.each do |m| method_defs[m][:required] += args[:required] if args[:required] method_defs[m][:optional] += args[:optional] if args[:optional] method_defs[m][:http_method] = args[:http_method] method_defs[m][:desc] = args[:desc] method_defs[m][:result_class] = args[:result_class] method_defs[m][:query] = args[:query] method_defs[m][:exe] = args[:exe] method_defs[m][:map_required_args] = args[:map_required_args] method_defs[m][:banner] = args[:banner] method_defs[m][:diagnostics] = args[:diagnostics] end end |
#desc(meth) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
137 138 139 |
# File 'lib/synaptic4r/rest.rb', line 137 def desc(meth) args[meth][:desc] end |
#diagnostics(meth) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
152 153 154 |
# File 'lib/synaptic4r/rest.rb', line 152 def diagnostics(meth) args[meth][:diagnostics].nil? ? true : args[meth][:diagnostics] end |
#emc_headers ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
178 179 180 |
# File 'lib/synaptic4r/rest.rb', line 178 def emc_headers arg_defs.inject([]){|r, (a, d)| d[:header].eql?(:emc) ? r.push(a) : r} end |
#exclusive_rest_args(meth) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
117 118 119 |
# File 'lib/synaptic4r/rest.rb', line 117 def exclusive_rest_args(meth) args[meth][:required].inject([]){|r,a| a.kind_of?(Array) ? r << a : r} end |
#exe(meth) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
142 143 144 |
# File 'lib/synaptic4r/rest.rb', line 142 def exe(meth) args[meth][:exe] end |
#has_rest_method?(meth) ⇒ Boolean
.….….….….….….….….….….….….….….….….….….….….….….….….……
93 94 95 |
# File 'lib/synaptic4r/rest.rb', line 93 def has_rest_method?(meth) rest_methods.include?(meth) end |
#header_args(meth) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
172 173 174 175 |
# File 'lib/synaptic4r/rest.rb', line 172 def header_args(meth) unary_rest_args(meth) + exclusive_rest_args(meth).flatten + optional_rest_args(meth) - non_header_args(meth) end |
#http_method(meth) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
102 103 104 |
# File 'lib/synaptic4r/rest.rb', line 102 def http_method(meth) args[meth][:http_method] end |
#map_required_args(meth) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
157 158 159 |
# File 'lib/synaptic4r/rest.rb', line 157 def map_required_args(meth) args[meth][:map_required_args] end |
#method_defs ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
57 58 59 |
# File 'lib/synaptic4r/rest.rb', line 57 def method_defs @@method_defs end |
#non_header_args(meth) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
183 184 185 |
# File 'lib/synaptic4r/rest.rb', line 183 def non_header_args(meth) arg_defs.inject([]){|r, (a, d)| d[:header].eql?(:none) ? r.push(a) : r} end |
#optional_rest_args(meth) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
122 123 124 |
# File 'lib/synaptic4r/rest.rb', line 122 def optional_rest_args(meth) args[meth][:optional] + args_all_methods(:optional) end |
#query(meth) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
167 168 169 |
# File 'lib/synaptic4r/rest.rb', line 167 def query(meth) args[meth][:query] end |
#required_rest_args(meth) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
107 108 109 |
# File 'lib/synaptic4r/rest.rb', line 107 def required_rest_args(meth) args[meth][:required] + args_all_methods(:required) end |
#rest_arg(arg) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
127 128 129 |
# File 'lib/synaptic4r/rest.rb', line 127 def rest_arg(arg) arg_defs[arg] end |
#rest_methods ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
98 99 100 |
# File 'lib/synaptic4r/rest.rb', line 98 def rest_methods args.keys.inject([]){|r,m| m.eql?(:all) ? r : r << m} end |
#result_class(meth) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
162 163 164 |
# File 'lib/synaptic4r/rest.rb', line 162 def result_class(meth) args[meth][:result_class] end |
#unary_rest_args(meth) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….……
112 113 114 |
# File 'lib/synaptic4r/rest.rb', line 112 def unary_rest_args(meth) args[meth][:required].inject([]){|r,a| a.kind_of?(Array) ? r : r << a} end |