By: Tomas Countz Room: Portland BR 254
- 10:40am-11:10am Leveling up. From Planning to Production BR 254
Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.
class ErrorSerializer | |
attr_accessor :request, :params, :errors | |
def initialize(request, params, errors = [], exception = nil) | |
@request = request | |
@params = params | |
@errors = errors | |
@exception = exception | |
end |
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 |
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. |
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: { |
// // 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) { |
# frozen_string_literal: true | |
require 'phlex' | |
require 'vite_ruby' | |
module ViteRephlex | |
module PhlexHelpers | |
class OohBabyILikeItRaw < Phlex::HTML | |
def initialize(tag:) | |
@tag = tag |
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) |
class Response | |
attr_reader :status, :data | |
def initialize(status, data) | |
@status = status | |
@data = data | |
end | |
def deconstruct | |
by_status |