Skip to content

Instantly share code, notes, and snippets.

View sclinede's full-sized avatar

Sara Dolganov sclinede

View GitHub Profile
@sclinede
sclinede / pipelines.rb
Last active September 24, 2023 11:10
Sagas implementation in pure Ruby (pre-DirtyPipelines gem)
class DirtyPipeline::Action
module WrappedCall
def call
Events.publish! Event.generate(self)
super
end
end
class << self
attr_accessor :attempted_event_klass, :pipeline, :timeout
# Usage:
#
# class Mail
# include SimpleStateMachine
#
# self.initial_state = 'unread'
# self.transitions_map = {
# read: {from: 'unread', to: 'read'},
# unread: {from: 'any', to: 'unread'},
# delete: {from: 'any', to: 'deleted'},
module SimpleRailway
class Result
attr_accessor :success, :data
def initialize(success, data)
@success = success
@data = data
end
def success?; !!success; end
def failure?; !success?; end
@sclinede
sclinede / saga.rb
Last active March 6, 2022 06:09
Example of Full Saga implementation in Ruby (with Usage example, also)
class Saga
class << self
def with_redis; raise NotImplementedError; end
attr_accessor :cleanup_delay, :queue, :last_txid
def queue
Thread.current[:saga_queue] ||= []
end
def last_txid

Keybase proof

I hereby claim:

  • I am sclinede on github.
  • I am sclinede (https://keybase.io/sclinede) on keybase.
  • I have a public key ASDUo5iyfIIqj7mP4hqtK0zJCXexqsJsNf_fdOSLBRWUwQo

To claim this, I am signing this object:

@sclinede
sclinede / yardoc_cheatsheet.md
Created December 24, 2016 12:00 — forked from chetan/yardoc_cheatsheet.md
YARD cheatsheet

YARD CHEATSHEET http://yardoc.org

cribbed from http://pastebin.com/xgzeAmBn

Templates to remind you of the options and formatting for the different types of objects you might want to document using YARD.

Modules

Namespace for classes and modules that handle serving documentation over HTTP

# Public: Виджет 'Акции компании на главной ск'
#
# Возвращает публикуемые, не истекшие, одобренные или на модерации, отмеченные for_home_page,
# наиболее свежие по дате создания акции
#
# Examples
#
# presenter 'apress/deals/front/offer', :latest_company_offers, company, {limit: 3}
#
# company - Company - компания, акции которой необходимо получить
def filter_by_auths(joins)
return unless filtered_by_int?(:auths_in_curr_month_from) || filtered_by_int?(:auths_in_curr_month_to) ||
filtered_by_int?(:auths_in_prev_month_from) || filtered_by_int?(:auths_in_prev_month_to)
auth_join_conditions = {
:auths_in_curr_month_from => " AND #{COS}.visits_in_current_month >= %{val}",
:auths_in_curr_month_to => " AND #{COS}.visits_in_current_month <= %{val}",
:auths_in_prev_month_from => " AND #{COS}.visits_in_prev_month >= %{val}",
:auths_in_prev_month_to => " AND #{COS}.visits_in_prev_month <= %{val}"
}.map! do |filter, condition|
class Admin::BaseFilrator
def filtered_by?()
end
def get_filter()
end
end
class Admin::CompaniesFiltrator < Admin::BaseFiltrator
pattr_initialize :params
Create
<input class="js-deals-rubric-id" type="hidden" value="237761" name="offer[offer_rubric_attributes][rubric_id]">
<input class="js-deals-rubric-id" type="hidden" value="#{offer.id}" name="offer[offer_rubric_attributes][offer_id]">
Update:
<input class="js-deals-offer-rubric-id" type="hidden" value="#{offer.offer_rubric.id}" name="offer[offer_rubric_attributes][id]">
<input class="js-deals-rubric-id" type="hidden" value="237761" name="offer[offer_rubric_attributes][rubric_id]">
<input class="js-deals-rubric-id" type="hidden" value="#{offer.id}" name="offer[offer_rubric_attributes][offer_id]">
Destroy: