This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
class OperationProxyContainer # :nodoc: | |
extend Dry::Container::Mixin | |
Import = Dry::AutoInject(self) | |
register 'make_document_file' do | |
MakeOperationProxyDocumentFileService | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
class AsyncJobController < ApplicationController # :nodoc: | |
include ActionController::Live | |
before_action :initialize_job_id, only: :status_live | |
JOB_DATA_KEYS = %i[pct_complete status message].freeze | |
PCT_FINISHED = 100 | |
STATUS_FINISHED = 'complete' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# SaveResource предназначен для созданиия записи в БД с nested_attributes (или без них). | |
# Особенности: | |
# * если у записи уже есть persisted nested records и при обновлении их атрибуты не были переданы, то такие записи будут удалены; | |
# * перед сохранением записи в БД, с ней можно выполнить любое действие (например установить дефолтные параметры) с помощью передачи блока в конструктор. | |
# Примеры вызова: | |
def create | |
update_position = ->(operation) { operation.position = operation.user.positions.first! } | |
service = SaveResource::Common.new(Operation, params[:operation], &update_position) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
# parse react json schema (https://github.com/mozilla-services/react-jsonschema-form) | |
# return Array with elements: Symbol, Special Hash | |
# Symbol - field name | |
# Special Hash: Hash, where | |
# * key - nested fields name, | |
# * value - | |
# Hash: key - nested object id, value - Array with elements: Symbol or Special Hash |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Checkout | |
attr_reader :items, :pricing_rules | |
def initialize(pricing_rules) | |
@pricing_rules = pricing_rules | |
@items = [] | |
end | |
def add(item) | |
items.push item |