Module: EasyqaApi::ClassMethodsSettable
- Included in:
- Item
- Defined in:
- lib/easyqa_api/helpers/class_methods_settable.rb
Overview
This module provides extends instance methods to class
Constant Summary collapse
- METHODS =
List of allowed instance methods
[:create, :show, :update, :delete].freeze
Instance Method Summary collapse
-
#install_class_methods!(options = {}) ⇒ Object
Provide instance methods to class.
Instance Method Details
#install_class_methods!(options = {}) ⇒ Object
Provide instance methods to class
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/easyqa_api/helpers/class_methods_settable.rb', line 16 def install_class_methods!( = {}) METHODS.each do |method_name| define_singleton_method method_name do |*attrs| instance = new instance.install_variables!( instance.send(method_name, *attrs).merge(attrs.find { |attr| attr.is_a? Hash } || {}) ) instance end if method_permitted?(, method_name) end end |