Skip to content

Instantly share code, notes, and snippets.

@joegaudet
joegaudet / configure_protocol_example.rb
Created November 24, 2018 18:27
configure_protocol
# If a dependency exposes the interface #configure, call it on instantiation with with the dependant
# example
class Utils
class Logger
attr_accessor :log_subject
dependency :logger, Logger, instance: Rails.logger
require 'test_helper'
module Ordering
module Validate
class AutoFinalizeTest < ActiveSupport::TestCase
describe 'validating whether or not we can auto finalize an order' do
describe 'with feature disabled' do
it 'returns true' do
What went wrong:
A problem occurred configuring project ':app'.
> java.lang.NullPointerException (no error message)
* Try:
Run with --info or --debug option to get more log output.
* Exception is:
org.gradle.api.ProjectConfigurationException: A problem occurred configuring project ':app'.
at org.gradle.configuration.project.LifecycleProjectEvaluator.addConfigurationFailure(LifecycleProjectEvaluator.java:79)
at org.gradle.configuration.project.LifecycleProjectEvaluator.notifyAfterEvaluate(LifecycleProjectEvaluator.java:74)
at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:61)
class Invoice
%w(sender_details recipient_details).each do |method|
define_method method do
attributes[method]
end
end
%w(total_amount tax_amount).each do |meth|
define_method("#{meth}=") do |value|
module Sso
module Saml
class Consume < FoodeeService
dependency :find_user, ::Queries::User::FindByEmail
dependency :create_user, Sso::Commands::CreateUser
dependency :sync_teams, Teams::SyncEnterpriseUser
dependency :response_adapter, Adapters::Response
def call(saml_response, url)
import Ember from 'ember';
import ENV from 'star-fox/config/environment';
const {
Object,
Component,
run,
observer
} = Ember;
module Fooo
class FindById
def call(id)
Foo.find(id)
end
end
class FindStatus
def call(id, name)
Foo.find(id).where(status: name)
@joegaudet
joegaudet / bad_state.rb
Last active August 24, 2018 21:51 — forked from jilucev/bad_state.rb
Enema of the state
# frozen_string_literal: true
module Hodor
class MainService
def initialize(
foo_klass: Foo
bar_service: Hodor::BarService.new,
baz_service: Hodor::BazService.new,
qux_service: Hodor::QuxService.new
)
class ObjectWithState
attr_accessor :foo
def call(bar)
self.foo = bar
bar
end