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
261 262 263 |
# File 'lib/apipie_dsl/dsl.rb', line 261 def app_info(app_info) dsl_data[:app_info] = app_info end |
#class_description(&block) ⇒ Object
265 266 267 268 269 270 271 272 273 |
# File 'lib/apipie_dsl/dsl.rb', line 265 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.
347 348 349 |
# File 'lib/apipie_dsl/dsl.rb', line 347 def default_prop_group_scope class_scope end |
#define_prop_group(name, &block) ⇒ Object
317 318 319 |
# File 'lib/apipie_dsl/dsl.rb', line 317 def define_prop_group(name, &block) ApipieDSL.define_prop_group(class_scope, name, &block) end |
#name(new_name) ⇒ Object Also known as: label
275 276 277 |
# File 'lib/apipie_dsl/dsl.rb', line 275 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.
324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 |
# File 'lib/apipie_dsl/dsl.rb', line 324 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
300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 |
# File 'lib/apipie_dsl/dsl.rb', line 300 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
280 281 282 |
# File 'lib/apipie_dsl/dsl.rb', line 280 def refs(*class_names) dsl_data[:refs] = class_names end |
#sections(sec_or_options, options = {}) ⇒ Object
285 286 287 288 289 290 291 292 293 294 295 296 297 298 |
# File 'lib/apipie_dsl/dsl.rb', line 285 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 |