Module: Quiver::Patcher
- Defined in:
- lib/quiver/patcher.rb
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary collapse
-
#current_user ⇒ Object
Returns the value of attribute current_user.
-
#operation ⇒ Object
Returns the value of attribute operation.
Class Method Summary collapse
Instance Method Summary collapse
- #initialize(operation, extra_params) ⇒ Object
- #internal_call(_) ⇒ Object
- #params ⇒ Object
- #request_path ⇒ Object
- #request_path_with_query ⇒ Object
- #run ⇒ Object
- #serialize_with(data) ⇒ Object
Instance Attribute Details
#current_user ⇒ Object
Returns the value of attribute current_user.
53 54 55 |
# File 'lib/quiver/patcher.rb', line 53 def current_user @current_user end |
#operation ⇒ Object
Returns the value of attribute operation.
53 54 55 |
# File 'lib/quiver/patcher.rb', line 53 def operation @operation end |
Class Method Details
.included(host) ⇒ Object
3 4 5 6 |
# File 'lib/quiver/patcher.rb', line 3 def self.included(host) host.send(:include, AbstractAction) host.extend(ClassMethods) end |
Instance Method Details
#initialize(operation, extra_params) ⇒ Object
55 56 57 58 |
# File 'lib/quiver/patcher.rb', line 55 def initialize(operation, extra_params) self.extra_params = extra_params || {} self.operation = operation end |
#internal_call(_) ⇒ Object
64 65 66 |
# File 'lib/quiver/patcher.rb', line 64 def internal_call(_) serialize_with(action) end |
#params ⇒ Object
68 69 70 71 72 73 74 75 76 |
# File 'lib/quiver/patcher.rb', line 68 def params @params ||= begin if operation['value'].respond_to?(:to_h) && self.class.get_params_attributes_klass self.class.get_params_attributes_klass.new(extra_params.merge({data: operation['value'].to_h})) else extra_params.merge({data: operation['value']}) end end end |
#request_path ⇒ Object
82 83 84 |
# File 'lib/quiver/patcher.rb', line 82 def request_path @request_path ||= operation['path'] end |
#request_path_with_query ⇒ Object
86 87 88 |
# File 'lib/quiver/patcher.rb', line 86 def request_path_with_query request_path end |
#run ⇒ Object
60 61 62 |
# File 'lib/quiver/patcher.rb', line 60 def run internal_call(nil) end |
#serialize_with(data) ⇒ Object
78 79 80 |
# File 'lib/quiver/patcher.rb', line 78 def serialize_with(data) self.class.serializer.new({collections: data}).serialize(context: self) end |