Module: ApipieDSL::Klass
- Included in:
- Delegatable::Delegatee, Validator::HashValidator
- Defined in:
- lib/apipie_dsl/dsl.rb
Instance Method Summary collapse
- #app_info(app_info) ⇒ Object
- #class_description(&block) ⇒ Object
-
#default_prop_group_scope ⇒ Object
Where the group definition should be looked up when no scope given.
- #define_prop_group(name, &block) ⇒ Object
- #name(new_name) ⇒ Object (also: #label)
-
#prop_group(name, scope_or_options = nil, options = {}) ⇒ Object
Reuses param group for this method.
- #property(name, retobj_or_options, desc_or_options = nil, options = {}, &block) ⇒ Object (also: #prop)
- #refs(*class_names) ⇒ Object (also: #referenced_on)
- #sections(sec_or_options, options = {}) ⇒ Object
Instance Method Details
#app_info(app_info) ⇒ Object
253 254 255 |
# File 'lib/apipie_dsl/dsl.rb', line 253 def app_info(app_info) dsl_data[:app_info] = app_info end |
#class_description(&block) ⇒ Object
257 258 259 260 261 262 263 264 265 |
# File 'lib/apipie_dsl/dsl.rb', line 257 def class_description(&block) dsl_data = apipie_eval_dsl(&block) dsl_data[:dsl_versions] = ApipieDSL.class_versions(class_scope) if dsl_data[:dsl_versions].empty? versions = dsl_data[:dsl_versions] versions.map do |version| ApipieDSL.define_class_description(class_scope, version, dsl_data) end ApipieDSL.set_class_versions(class_scope, versions) end |
#default_prop_group_scope ⇒ Object
Where the group definition should be looked up when no scope given. This is expected to return a class.
339 340 341 |
# File 'lib/apipie_dsl/dsl.rb', line 339 def default_prop_group_scope class_scope end |
#define_prop_group(name, &block) ⇒ Object
309 310 311 |
# File 'lib/apipie_dsl/dsl.rb', line 309 def define_prop_group(name, &block) ApipieDSL.define_prop_group(class_scope, name, &block) end |
#name(new_name) ⇒ Object Also known as: label
267 268 269 |
# File 'lib/apipie_dsl/dsl.rb', line 267 def name(new_name) dsl_data[:class_name] = new_name end |
#prop_group(name, scope_or_options = nil, options = {}) ⇒ Object
Reuses param group for this method. The definition is looked up in scope of this class. If the group was defined in different class, the second param can be used to specify it.
316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 |
# File 'lib/apipie_dsl/dsl.rb', line 316 def prop_group(name, = nil, = {}) if .is_a?(Hash) .merge!() scope = [:scope] else scope = end scope ||= default_prop_group_scope @current_prop_group = { scope: scope, name: name, options: } @meta = ([:meta] || {}).tap { || [:class_scope] = class_scope } instance_exec(&ApipieDSL.get_prop_group(scope, name)) ensure @current_prop_group = nil @meta = nil end |
#property(name, retobj_or_options, desc_or_options = nil, options = {}, &block) ⇒ Object Also known as: prop
292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 |
# File 'lib/apipie_dsl/dsl.rb', line 292 def property(name, , = nil, = {}, &block) if .is_a?(Hash) .merge!() elsif !.nil? [:desc] = end [:property] = true returns = returns(, , , &block) prop_dsl_data = { short_description: [:desc], returns: returns } dsl_data[:properties] << [name, prop_dsl_data] end |
#refs(*class_names) ⇒ Object Also known as: referenced_on
272 273 274 |
# File 'lib/apipie_dsl/dsl.rb', line 272 def refs(*class_names) dsl_data[:refs] = class_names end |
#sections(sec_or_options, options = {}) ⇒ Object
277 278 279 280 281 282 283 284 285 286 287 288 289 290 |
# File 'lib/apipie_dsl/dsl.rb', line 277 def sections(, = {}) if .is_a?(Hash) .merge!() elsif !.nil? [:only] = end only = [[:only]].flatten || ApipieDSL.configuration.sections except = if [:except] [[:except]].flatten else [] end dsl_data[:sections] = only - except end |