Skip to content

Instantly share code, notes, and snippets.

View RomanTurner's full-sized avatar
🤫

Roman RomanTurner

🤫
View GitHub Profile
@RomanTurner
RomanTurner / response_values.rb
Last active February 19, 2024 03:44
structs to model values in our domain
module PaymentProcessor
module Response
class ResponseStruct < Struct
def self.build(args)
return if args.blank?
# this filters the fields from the response that we don't need or want.
# but it also keeps the kwargs strict.
new(args.slice(*members)
end
@RomanTurner
RomanTurner / event_base.rb
Created April 7, 2024 23:44
Ruby Simple Event as State Machine
module Event
class Base < ActiveRecord::Base
self.table_name = 'events'
# Callbacks to enforce state transitions logic
before_update :validate_status_transition
enum status: {
enqueued: 0,
processing: 1,