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



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

def _apipie_concern_data
  @_apipie_concern_data ||= []
end

#_apipie_concern_update_api_blocksObject



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

def _apipie_concern_update_api_blocks
  @_apipie_concern_update_api_blocks ||= []
end

#apipie_concern?Boolean

Returns:

  • (Boolean)


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

def apipie_concern?
  true
end

#included(controller) ⇒ Object

the concern was included into a controller



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

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



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

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



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

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