Module: Apipie::DSL::Concern

Includes:
Action, Base, Common, Param
Defined in:
lib/apipie/dsl_definition.rb

Instance Attribute Summary

Attributes included from Base

#api_params, #apipie_resource_descriptions

Instance Method Summary collapse

Methods included from Param

#_default_param_group_scope, #param, #param_group, #property, #returns

Methods included from Action

#api, #api!, #def_param_group, #example, #resource_description, #see, #show

Methods included from Common

#_apipie_define_validators, #_apipie_get_method_params, #_apipie_handle_validate_key_error, #_apipie_save_method_params, #api_versions, #desc, #document, #error, #formats, #header, #meta, #tags

Methods included from Base

#_apipie_eval_dsl

Instance Method Details

#_apipie_concern_dataObject



582
583
584
# File 'lib/apipie/dsl_definition.rb', line 582

def _apipie_concern_data
  @_apipie_concern_data ||= []
end

#_apipie_concern_update_api_blocksObject



586
587
588
# File 'lib/apipie/dsl_definition.rb', line 586

def _apipie_concern_update_api_blocks
  @_apipie_concern_update_api_blocks ||= []
end

#apipie_concern?Boolean

Returns:

  • (Boolean)


590
591
592
# File 'lib/apipie/dsl_definition.rb', line 590

def apipie_concern?
  true
end

#included(controller) ⇒ Object

the concern was included into a controller



570
571
572
573
574
575
576
577
578
579
580
# File 'lib/apipie/dsl_definition.rb', line 570

def included(controller)
  super
  _apipie_concern_data.each do |method_name, _apipie_dsl_data|
    # remove method description if exists and create new one
    description = Apipie.define_method_description(controller, method_name, _apipie_dsl_data)
    controller._apipie_define_validators(description)
  end
  _apipie_concern_update_api_blocks.each do |(methods, block)|
    controller.apipie_update_methods(methods, &block)
  end
end

#method_added(method_name) ⇒ Object

create method api and redefine newly added method



595
596
597
598
599
600
601
602
603
# File 'lib/apipie/dsl_definition.rb', line 595

def method_added(method_name) #:doc:
  super

  return if ! Apipie.active_dsl? || !_apipie_dsl_data[:api]

  _apipie_concern_data << [method_name, _apipie_dsl_data.merge(:from_concern => true)]
ensure
  _apipie_dsl_data_clear
end

#update_api(*methods, &block) ⇒ Object



605
606
607
# File 'lib/apipie/dsl_definition.rb', line 605

def update_api(*methods, &block)
  _apipie_concern_update_api_blocks << [methods, block]
end