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
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, |
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
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 |
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 Response | |
attr_reader :status, :data | |
def initialize(status, data) | |
@status = status | |
@data = data | |
end | |
def deconstruct | |
by_status |
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
require "haml" | |
module Hamlet | |
def self.included(base) | |
base.extend ClassMethods | |
end | |
def render | |
engine = Haml::Template.new { self.class.get_element } | |
engine.render(self) |
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 | |
require 'phlex' | |
require 'vite_ruby' | |
module ViteRephlex | |
module PhlexHelpers | |
class OohBabyILikeItRaw < Phlex::HTML | |
def initialize(tag:) | |
@tag = tag |
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
// // Generate a large sorted array of random integers | |
const arraySize = 1500; | |
const amountOfRecipes = 1000; | |
const sortedArray = Array.from({ length: arraySize }, (_, i) => i).sort( | |
(a, b) => a - b | |
); | |
const jsonArray = JSON.stringify(sortedArray); | |
function binarySearch(arr, val) { |
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 StyledComponent < Phlex::HTML | |
STYLES = { | |
container: { | |
xs: "mx-auto max-w-7xl px-6 py-24", | |
sm: "sm:py-32", | |
lg: "lg:px-8" | |
}, | |
get_started: { |
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 Roda | |
module RodaPlugins | |
module Phlex | |
def self.configure(app, opts) | |
app.opts[:class_name] = app.name | |
app.opts[:phlex] = opts | |
end | |
module InstanceMethods | |
# Render a component with the default layout. |
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
module ViteRephlex | |
module PhlexHelpers | |
class OohBabyILikeItRaw < Phlex::HTML | |
def initialize(tag:) | |
@tag = tag | |
end | |
def template | |
@tag.is_a?(Array) ? @tag.each { |t| unsafe_raw(t) } : unsafe_raw(@tag) | |
end | |
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
class ErrorSerializer | |
attr_accessor :request, :params, :errors | |
def initialize(request, params, errors = [], exception = nil) | |
@request = request | |
@params = params | |
@errors = errors | |
@exception = exception | |
end |
NewerOlder