Class: InstantApi::Controller::Builder
- Inherits:
-
Object
- Object
- InstantApi::Controller::Builder
- Defined in:
- lib/instant_api/controller/builder.rb
Instance Attribute Summary collapse
-
#controller_name ⇒ Object
readonly
Returns the value of attribute controller_name.
-
#method_names ⇒ Object
readonly
Returns the value of attribute method_names.
Instance Method Summary collapse
- #build_class ⇒ Object
-
#initialize(controller_name, method_names) ⇒ Builder
constructor
A new instance of Builder.
Constructor Details
#initialize(controller_name, method_names) ⇒ Builder
Returns a new instance of Builder.
16 17 18 19 20 21 |
# File 'lib/instant_api/controller/builder.rb', line 16 def initialize(controller_name, method_names) @controller_name = controller_name @method_names = method_names.map(&:to_sym) @method_names << :resource if @method_names != [:index] end |
Instance Attribute Details
#controller_name ⇒ Object (readonly)
Returns the value of attribute controller_name.
15 16 17 |
# File 'lib/instant_api/controller/builder.rb', line 15 def controller_name @controller_name end |
#method_names ⇒ Object (readonly)
Returns the value of attribute method_names.
15 16 17 |
# File 'lib/instant_api/controller/builder.rb', line 15 def method_names @method_names end |
Instance Method Details
#build_class ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/instant_api/controller/builder.rb', line 23 def build_class controller_class_name = "#{controller_name.camelize}Controller" controller = Class.new(ActionController::API) controller.send(:include, InstantApi::Controller::ExceptionHandler) build_methods(controller) Object.const_set(controller_class_name, controller) end |