source
stringclasses
1 value
repo
stringlengths
5
63
repo_url
stringlengths
24
82
path
stringlengths
5
167
language
stringclasses
1 value
license
stringclasses
5 values
stars
int64
10
51.4k
ref
stringclasses
23 values
size_bytes
int64
200
258k
text
stringlengths
137
258k
github
lulalala/adequate_errors
https://github.com/lulalala/adequate_errors
lib/adequate_errors/nested_error.rb
Ruby
mit
47
master
938
module AdequateErrors # Represents one single error # @!attribute [r] base # @return [ActiveModel::Base] the object which the error belongs to # @!attribute [r] attribute # @return [Symbol] attribute of the object which the error belongs to # @!attribute [r] type # @return [Symbol] error's type # ...
github
lulalala/adequate_errors
https://github.com/lulalala/adequate_errors
lib/adequate_errors/errors.rb
Ruby
mit
47
master
3,523
require 'active_model/errors' require 'forwardable' require 'adequate_errors/error' require 'adequate_errors/nested_error' module AdequateErrors # Collection of {Error} objects. # Provides convenience methods to access these errors. # It is accessed via +model.errors.adequate+ class Errors include Enumerab...
github
lulalala/adequate_errors
https://github.com/lulalala/adequate_errors
lib/adequate_errors/error.rb
Ruby
mit
47
master
5,144
module AdequateErrors # Represents one single error # @!attribute [r] base # @return [ActiveModel::Base] the object which the error belongs to # @!attribute [r] attribute # @return [Symbol] attribute of the object which the error belongs to # @!attribute [r] type # @return [Symbol] error's type # ...
github
dfurber/ar_doc_store
https://github.com/dfurber/ar_doc_store
ar_doc_store.gemspec
Ruby
mit
47
master
1,354
# coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'ar_doc_store/version' Gem::Specification.new do |spec| spec.name = "ar_doc_store" spec.version = ArDocStore::VERSION spec.authors = ["David Furber"] spec.email ...
github
dfurber/ar_doc_store
https://github.com/dfurber/ar_doc_store
Rakefile
Ruby
mit
47
master
668
require "bundler/gem_tasks" require 'rake/testtask' Rake::TestTask.new do |t| t.pattern = "test/**/*_test.rb" end namespace :test do task :prepare_ar_doc_store do config = { adapter: 'postgresql', database: 'ar_doc_store_test', username: 'postgres', password: 'postgres' } require 'active_record' Acti...
github
dfurber/ar_doc_store
https://github.com/dfurber/ar_doc_store
lib/ar_doc_store.rb
Ruby
mit
47
master
2,277
# frozen_string_literal: true require "ar_doc_store/version" require "ar_doc_store/storage" require "ar_doc_store/embedding" require "ar_doc_store/model" require "ar_doc_store/embeddable_model" require "ar_doc_store/embedded_collection" module ArDocStore module Attributes autoload :Base, "ar_doc_store/attribut...
github
dfurber/ar_doc_store
https://github.com/dfurber/ar_doc_store
lib/ar_doc_store/storage.rb
Ruby
mit
47
master
1,156
# frozen_string_literal: true module ArDocStore module Storage def self.included(mod) mod.class_attribute :json_column mod.json_column ||= :data mod.class_attribute :json_attributes mod.json_attributes ||= HashWithIndifferentAccess.new mod.send :extend, ClassMethods end mo...
github
dfurber/ar_doc_store
https://github.com/dfurber/ar_doc_store
lib/ar_doc_store/model.rb
Ruby
mit
47
master
1,705
# frozen_string_literal: true module ArDocStore module Model def self.included(mod) mod.send :include, ArDocStore::Storage mod.send :include, ArDocStore::Embedding mod.send :include, InstanceMethods mod.after_initialize :assign_json_data mod.before_validation :save_json_data m...
github
dfurber/ar_doc_store
https://github.com/dfurber/ar_doc_store
lib/ar_doc_store/embedded_collection.rb
Ruby
mit
47
master
369
# frozen_string_literal: true module ArDocStore class EmbeddedCollection < Array attr_accessor :parent, :embedded_as def save parent.send :write_store_attribute, parent.json_column, embedded_as, as_json end def persist each &:persist end def inspect "ArDocStore::EmbeddedCo...
github
dfurber/ar_doc_store
https://github.com/dfurber/ar_doc_store
lib/ar_doc_store/embeddable_model.rb
Ruby
mit
47
master
2,997
# frozen_string_literal: true require 'securerandom' module ArDocStore module EmbeddableModel def self.included(mod) mod.send :include, ActiveModel::Model mod.send :include, ActiveModel::Attributes mod.send :include, ActiveModel::AttributeMethods mod.send :include, ActiveModel::Dirty ...
github
dfurber/ar_doc_store
https://github.com/dfurber/ar_doc_store
lib/ar_doc_store/embedding.rb
Ruby
mit
47
master
1,333
# frozen_string_literal: true module ArDocStore module Embedding def self.included(mod) mod.send :extend, ClassMethods mod.send :include, InstanceMethods end module ClassMethods def embeds_many(assn_name, *args) json_attribute assn_name, :embeds_many, *args end def...
github
dfurber/ar_doc_store
https://github.com/dfurber/ar_doc_store
lib/ar_doc_store/types/embeds_one.rb
Ruby
mit
47
master
902
# frozen_string_literal: true module ArDocStore module Types class EmbedsOne < ActiveModel::Type::Value attr_accessor :class_name def initialize(class_name) @class_name = class_name end def cast(value) @class_name = @class_name.constantize if class_name.respond_to?(:cons...
github
dfurber/ar_doc_store
https://github.com/dfurber/ar_doc_store
lib/ar_doc_store/types/embeds_many.rb
Ruby
mit
47
master
1,371
# frozen_string_literal: true module ArDocStore module Types class EmbedsMany < ActiveModel::Type::Value attr_accessor :class_name def initialize(class_name) @class_name = class_name end def cast(values) @class_name = @class_name.constantize if class_name.respond_to?(:co...
github
dfurber/ar_doc_store
https://github.com/dfurber/ar_doc_store
lib/ar_doc_store/attributes/date.rb
Ruby
mit
47
master
404
# frozen_string_literal: true module ArDocStore module Attributes class Date < Base def define_query_method model.class_eval <<-CODE, __FILE__, __LINE__ + 1 def #{attribute}? #{attribute}.present? end CODE end def type :date end ...
github
dfurber/ar_doc_store
https://github.com/dfurber/ar_doc_store
lib/ar_doc_store/attributes/array.rb
Ruby
mit
47
master
469
# frozen_string_literal: true module ArDocStore module Attributes class Array < Base def define_query_method model.class_eval <<-CODE, __FILE__, __LINE__ + 1 def #{attribute}? #{attribute}.present? end CODE end def type :array end ...
github
dfurber/ar_doc_store
https://github.com/dfurber/ar_doc_store
lib/ar_doc_store/attributes/embeds_many.rb
Ruby
mit
47
master
4,470
# frozen_string_literal: true module ArDocStore module Attributes class EmbedsMany < EmbedsBase private def store_attribute model.class_eval <<-CODE, __FILE__, __LINE__ + 1 attribute :#{attribute}, ArDocStore::Types::EmbedsMany.new("#{@class_name}") def #{attribute} ...
github
dfurber/ar_doc_store
https://github.com/dfurber/ar_doc_store
lib/ar_doc_store/attributes/integer.rb
Ruby
mit
47
master
269
# frozen_string_literal: true module ArDocStore module Attributes class Integer < Base def predicate 'int' end def type :number end def attribute_type ActiveModel::Type::Integer end end end end
github
dfurber/ar_doc_store
https://github.com/dfurber/ar_doc_store
lib/ar_doc_store/attributes/datetime.rb
Ruby
mit
47
master
416
# frozen_string_literal: true module ArDocStore module Attributes class Datetime < Base def define_query_method model.class_eval <<-CODE, __FILE__, __LINE__ + 1 def #{attribute}? #{attribute}.present? end CODE end def type :datetime ...
github
dfurber/ar_doc_store
https://github.com/dfurber/ar_doc_store
lib/ar_doc_store/attributes/boolean.rb
Ruby
mit
47
master
271
# frozen_string_literal: true module ArDocStore module Attributes class Boolean < Base def predicate 'bool' end def type :boolean end def attribute_type ActiveModel::Type::Boolean end end end end
github
dfurber/ar_doc_store
https://github.com/dfurber/ar_doc_store
lib/ar_doc_store/attributes/embeds_base.rb
Ruby
mit
47
master
835
# frozen_string_literal: true module ArDocStore module Attributes class EmbedsBase < Base attr_reader :class_name before_build :handle_options after_build :create_build_method after_build :create_ensure_method after_build :create_attributes_method after_build :create_validatio...
github
dfurber/ar_doc_store
https://github.com/dfurber/ar_doc_store
lib/ar_doc_store/attributes/decimal.rb
Ruby
mit
47
master
272
# frozen_string_literal: true module ArDocStore module Attributes class Decimal < Base def predicate 'number' end def type :number end def attribute_type ActiveModel::Type::Decimal end end end end
github
dfurber/ar_doc_store
https://github.com/dfurber/ar_doc_store
lib/ar_doc_store/attributes/callback_support.rb
Ruby
mit
47
master
501
# frozen_string_literal: true module ArDocStore module Attributes module CallbackSupport def self.included(mod) mod.send :include, ActiveSupport::Callbacks mod.send :extend, ClassMethods mod.define_callbacks :build end module ClassMethods def before_build(metho...
github
dfurber/ar_doc_store
https://github.com/dfurber/ar_doc_store
lib/ar_doc_store/attributes/base.rb
Ruby
mit
47
master
1,514
# frozen_string_literal: true module ArDocStore module Attributes class Base include CallbackSupport attr_accessor :conversion, :predicate, :options, :model, :attribute, :default after_build :add_ransacker after_build :define_query_method def self.build(model, attribute, options=...
github
dfurber/ar_doc_store
https://github.com/dfurber/ar_doc_store
lib/ar_doc_store/attributes/embeds_one.rb
Ruby
mit
47
master
2,047
# frozen_string_literal: true module ArDocStore module Attributes class EmbedsOne < EmbedsBase private def store_attribute model.class_eval <<-CODE, __FILE__, __LINE__ + 1 attribute :#{attribute}, ArDocStore::Types::EmbedsOne.new("#{@class_name}") def #{attribute} v...
github
dfurber/ar_doc_store
https://github.com/dfurber/ar_doc_store
lib/ar_doc_store/attributes/enumeration.rb
Ruby
mit
47
master
1,368
# frozen_string_literal: true module ArDocStore module Attributes class Enumeration < Base def build key = attribute.to_sym dictionary = options[:values] multiple = options[:multiple] strict = options[:strict] default_value = default model.class_eval do ...
github
dfurber/ar_doc_store
https://github.com/dfurber/ar_doc_store
lib/ar_doc_store/attributes/float.rb
Ruby
mit
47
master
267
# frozen_string_literal: true module ArDocStore module Attributes class Float < Base def predicate 'float' end def type :number end def attribute_type ActiveModel::Type::Float end end end end
github
dfurber/ar_doc_store
https://github.com/dfurber/ar_doc_store
lib/ar_doc_store/attributes/string.rb
Ruby
mit
47
master
226
# frozen_string_literal: true module ArDocStore module Attributes class String < Base def predicate 'text' end def attribute_type ActiveModel::Type::String end end end end
github
dfurber/ar_doc_store
https://github.com/dfurber/ar_doc_store
test/test_helper.rb
Ruby
mit
47
master
4,212
gem 'activerecord' gem 'minitest' gem 'ransack' require 'minitest/autorun' require 'active_record' require 'ransack' require_relative './../lib/ar_doc_store' ActiveRecord::Base.establish_connection(adapter: 'postgresql', database: 'ar_doc_store_test', username: 'postgres', password: 'postgres') require 'active_recor...
github
dfurber/ar_doc_store
https://github.com/dfurber/ar_doc_store
test/model_test.rb
Ruby
mit
47
master
787
require_relative './test_helper' class ModelTest < MiniTest::Test def test_save_with_validation b = Building.new name: 'test' assert b.save b.reload assert_equal 'test', b.name end def test_save_without_validation b = Building.new name: 'test' assert b.save(validate: false) b.reload ...
github
dfurber/ar_doc_store
https://github.com/dfurber/ar_doc_store
test/attributes/decimal_attribute_test.rb
Ruby
mit
47
master
812
require_relative './../test_helper' class DecimalAttributeTest < MiniTest::Test def test_attribute_on_model_init b = Building.new cost: 5.42 assert_equal 5.42, b.cost end def test_attribute_on_existing_model b = Building.new b.cost = 5.42 assert_equal 5.42, b.cost assert b.cost_change...
github
dfurber/ar_doc_store
https://github.com/dfurber/ar_doc_store
test/attributes/array_attribute_test.rb
Ruby
mit
47
master
771
require_relative './../test_helper' class ArrayAttributeTest < MiniTest::Test def test_attribute_on_model_init architects = %W{Bob John Billy Bob} b = Building.new architects: architects assert_equal architects, b.architects end def test_attribute_on_existing_model architects = %W{Bob John Bi...
github
dfurber/ar_doc_store
https://github.com/dfurber/ar_doc_store
test/attributes/integer_attribute_test.rb
Ruby
mit
47
master
1,310
require_relative './../test_helper' class IntegerAttributeTest < MiniTest::Test def test_string_attribute_on_model_init b = Building.new stories: 5 assert_equal 5, b.stories end def test_string_attribute_on_existing_model b = Building.new b.stories = 5 assert_equal 5, b.stories assert...
github
dfurber/ar_doc_store
https://github.com/dfurber/ar_doc_store
test/attributes/float_attribute_test.rb
Ruby
mit
47
master
831
require_relative './../test_helper' class FloatAttributeTest < MiniTest::Test def test_attribute_on_model_init b = Building.new height: 5.42 assert_equal 5.42, b.height end def test_attribute_on_existing_model b = Building.new b.height = 5.42 assert_equal 5.42, b.height assert b.heigh...
github
dfurber/ar_doc_store
https://github.com/dfurber/ar_doc_store
test/attributes/boolean_attribute_test.rb
Ruby
mit
47
master
1,027
require_relative './../test_helper' class BooleanAttributeTest < MiniTest::Test def test_attribute_on_model_init b = Building.new finished: true assert_equal true, b.finished end def test_attribute_on_existing_model b = Building.new b.finished = true assert_equal true, b.finished asse...
github
dfurber/ar_doc_store
https://github.com/dfurber/ar_doc_store
test/attributes/embeds_one_attribute_test.rb
Ruby
mit
47
master
2,137
require_relative './../test_helper' class EmbedsOneAttributeTest < MiniTest::Test def test_initialized_on_model_init entrance = Entrance.new name: 'Foo' b = Building.new entrance: entrance assert_equal entrance.name, b.entrance.name end def test_hash_on_model_init entrance = { name: 'Foo' } ...
github
dfurber/ar_doc_store
https://github.com/dfurber/ar_doc_store
test/attributes/datetime_attribute_test.rb
Ruby
mit
47
master
1,466
require_relative './../test_helper' class DatetimeAttributeTest < MiniTest::Test def test_attribute_on_model_init inspected_at = Time.new(1984, 3, 6) b = Building.new inspected_at: inspected_at assert inspected_at == b.inspected_at end def test_attribute_on_existing_model inspected_at = Time.ne...
github
dfurber/ar_doc_store
https://github.com/dfurber/ar_doc_store
test/attributes/string_attribute_test.rb
Ruby
mit
47
master
819
require_relative './../test_helper' class StringAttributeTest < MiniTest::Test def test_attribute_on_model_init b = Building.new name: 'test' assert_equal 'test', b.name end def test_attribute_on_existing_model b = Building.new b.name = 'test' assert_equal 'test', b.name assert b.name...
github
dfurber/ar_doc_store
https://github.com/dfurber/ar_doc_store
test/attributes/date_attribute_test.rb
Ruby
mit
47
master
1,326
require_relative './../test_helper' class DateAttributeTest < MiniTest::Test def test_attribute_on_model_init finished_on = Date.new(1984, 3, 6) b = Building.new finished_on: finished_on assert finished_on == b.finished_on end def test_attribute_on_existing_model finished_on = Date.new(1984, 3,...
github
dfurber/ar_doc_store
https://github.com/dfurber/ar_doc_store
test/attributes/enumeration_attribute_test.rb
Ruby
mit
47
master
2,039
require_relative './../test_helper' class EnumerationAttributeTest < MiniTest::Test def test_simple_enumeration_attribute b = Building.new construction: 'wood' assert_equal 'wood', b.construction end def test_multiple_enumeration_attribute b = Building.new multiconstruction: %w{wood plaster} ...
github
dfurber/ar_doc_store
https://github.com/dfurber/ar_doc_store
test/attributes/embeds_many_attribute_test.rb
Ruby
mit
47
master
2,065
require_relative './../test_helper' class EmbedsManyAttributeTest < MiniTest::Test def test_initialized_on_model_init r = Restroom.new name: 'Foo' b = Building.new restrooms: [r] assert_equal r.name, b.restrooms.first.name end def test_hash_on_model_init r = { name: 'Foo' } b = Building.new...
github
pstrzalk/ddd-example-in-ruby-on-rails
https://github.com/pstrzalk/ddd-example-in-ruby-on-rails
Gemfile
Ruby
mit
47
main
2,232
source "https://rubygems.org" git_source(:github) { |repo| "https://github.com/#{repo}.git" } ruby "3.1.2" # Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main" gem "rails", "~> 7" # The original asset pipeline for Rails [https://github.com/rails/sprockets-rails] gem "sprockets-rails" # Us...
github
pstrzalk/ddd-example-in-ruby-on-rails
https://github.com/pstrzalk/ddd-example-in-ruby-on-rails
db/schema.rb
Ruby
mit
47
main
1,942
# This file is auto-generated from the current state of the database. Instead # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. # # This file is the source Rails uses to define your schema when running `bin/rai...
github
pstrzalk/ddd-example-in-ruby-on-rails
https://github.com/pstrzalk/ddd-example-in-ruby-on-rails
db/seeds.rb
Ruby
mit
47
main
1,691
def print_header(label) puts "\n========================\n== #{label}" end contract_repository = CooperationNegotiation::Domain::ContractRepository.get admin_identity = '00000000-0000-0000-0000-000000000001' client_id = '00000000-0000-0000-0000-000000000007' CooperationNegotiation::Application::Services::PrepareDr...
github
pstrzalk/ddd-example-in-ruby-on-rails
https://github.com/pstrzalk/ddd-example-in-ruby-on-rails
db/migrate/20221123212818_create_dragon_hunt_parties.rb
Ruby
mit
47
main
217
class CreateDragonHuntParties < ActiveRecord::Migration[7.0] def change create_table :dragon_hunt_parties, id: :uuid do |t| t.uuid :client_id, index: { unique: true } t.timestamps end end end
github
pstrzalk/ddd-example-in-ruby-on-rails
https://github.com/pstrzalk/ddd-example-in-ruby-on-rails
db/migrate/20221123212610_create_cooperation_negotiation_contracts.rb
Ruby
mit
47
main
379
class CreateCooperationNegotiationContracts < ActiveRecord::Migration[7.0] def change create_table :cooperation_negotiation_contracts, id: :uuid do |t| t.uuid :client_id, index: { unique: true } t.boolean :client_signature, default: false t.boolean :company_signature, default: false t.tex...
github
pstrzalk/ddd-example-in-ruby-on-rails
https://github.com/pstrzalk/ddd-example-in-ruby-on-rails
db/migrate/20221124233218_create_read_models_signed_contracts.rb
Ruby
mit
47
main
228
class CreateReadModelsSignedContracts < ActiveRecord::Migration[7.0] def change create_table :read_models_signed_contracts, id: :uuid do |t| t.uuid :client_id t.text :text t.timestamps end end end
github
pstrzalk/ddd-example-in-ruby-on-rails
https://github.com/pstrzalk/ddd-example-in-ruby-on-rails
spec/rails_helper.rb
Ruby
mit
47
main
2,859
# This file is copied to spec/ when you run 'rails generate rspec:install' require 'spec_helper' ENV['RAILS_ENV'] ||= 'test' require_relative '../config/environment' # Prevent database truncation if the environment is production abort("The Rails environment is running in production mode!") if Rails.env.production? requ...
github
pstrzalk/ddd-example-in-ruby-on-rails
https://github.com/pstrzalk/ddd-example-in-ruby-on-rails
spec/spec_helper.rb
Ruby
mit
47
main
4,860
require "simplecov" SimpleCov.start "rails" do add_filter "app/channels/application_cable/channel.rb" add_filter "app/channels/application_cable/connection.rb" add_filter "app/jobs/application_job.rb" add_filter "app/mailers/application_mailer.rb" end # This file was generated by the `rails generate rspec:inst...
github
pstrzalk/ddd-example-in-ruby-on-rails
https://github.com/pstrzalk/ddd-example-in-ruby-on-rails
spec/modules/authorization/application/api_spec.rb
Ruby
mit
47
main
1,348
require_relative "../../../rails_helper" module Authorization module Application describe Api do describe '.identity_in_role?' do context 'when checking an admin identity' do let(:identity) { '00000000-0000-0000-0000-000000000001' } it { expect(described_class.identity_in_role?...
github
pstrzalk/ddd-example-in-ruby-on-rails
https://github.com/pstrzalk/ddd-example-in-ruby-on-rails
spec/modules/dragon_hunt/application/handlers/cooperation_negotiation/contract_signed_spec.rb
Ruby
mit
47
main
744
require_relative "../../../../../rails_helper" module DragonHunt module Application module Handlers module CooperationNegotiation describe ContractSigned do describe '.call' do let(:id) { '00000000-0000-0000-0000-000000000001' } let(:client_id) { '00000000-0000-000...
github
pstrzalk/ddd-example-in-ruby-on-rails
https://github.com/pstrzalk/ddd-example-in-ruby-on-rails
spec/modules/dragon_hunt/domain/party_spec.rb
Ruby
mit
47
main
911
require_relative "../../../rails_helper" module DragonHunt module Domain describe Party do let(:id) { SecureRandom.uuid } let(:client_id) { SecureRandom.uuid } describe '.assemble' do let(:assembled_party) { described_class.assemble(client_id: client_id) } it { expect(assemble...
github
pstrzalk/ddd-example-in-ruby-on-rails
https://github.com/pstrzalk/ddd-example-in-ruby-on-rails
spec/modules/dragon_hunt/infrastructure/db_party_spec.rb
Ruby
mit
47
main
250
require_relative "../../../rails_helper" module DragonHunt module Infrastructure describe DbParty do it "can be persisted" do expect { described_class.create }.to change(described_class, :count).by(1) end end end end
github
pstrzalk/ddd-example-in-ruby-on-rails
https://github.com/pstrzalk/ddd-example-in-ruby-on-rails
spec/modules/dragon_hunt/infrastructure/db_party_repository_spec.rb
Ruby
mit
47
main
1,795
require_relative "../../../rails_helper" module DragonHunt module Infrastructure describe DbPartyRepository do subject(:repository) { described_class.new } let(:id) { "00000000-0000-0000-0000-000000000001" } let(:client_id) { "00000000-0000-0000-0000-000000000002" } describe '#of_id' do...
github
pstrzalk/ddd-example-in-ruby-on-rails
https://github.com/pstrzalk/ddd-example-in-ruby-on-rails
spec/modules/cooperation_negotiation/domain/contract_spec.rb
Ruby
mit
47
main
5,732
require_relative "../../../rails_helper" module CooperationNegotiation module Domain describe Contract do let(:id) { SecureRandom.uuid } let(:client_id) { SecureRandom.uuid } describe '.prepare_draft' do it 'initializes a contract with an event' do time = '2023-01-01 23:18:44...
github
pstrzalk/ddd-example-in-ruby-on-rails
https://github.com/pstrzalk/ddd-example-in-ruby-on-rails
spec/modules/cooperation_negotiation/domain/events/contract_signed_spec.rb
Ruby
mit
47
main
539
require_relative "../../../../rails_helper" module CooperationNegotiation module Domain module Events describe ContractSigned do it 'has attributes' do event = described_class.new event.text = :foo event.contract_id = :boo event.client_id = :moo eve...
github
pstrzalk/ddd-example-in-ruby-on-rails
https://github.com/pstrzalk/ddd-example-in-ruby-on-rails
spec/modules/cooperation_negotiation/domain/events/contract_text_modified_spec.rb
Ruby
mit
47
main
483
require_relative "../../../../rails_helper" module CooperationNegotiation module Domain module Events describe ContractTextModified do it 'has attributes' do event = described_class.new event.text = :foo event.contract_id = :boo event.time = :zoo e...
github
pstrzalk/ddd-example-in-ruby-on-rails
https://github.com/pstrzalk/ddd-example-in-ruby-on-rails
spec/modules/cooperation_negotiation/domain/events/contract_draft_prepared_spec.rb
Ruby
mit
47
main
494
require_relative "../../../../rails_helper" module CooperationNegotiation module Domain module Events describe ContractDraftPrepared do it 'has attributes' do event = described_class.new event.contract_id = :boo event.client_id = :moo event.time = :zoo ...
github
pstrzalk/ddd-example-in-ruby-on-rails
https://github.com/pstrzalk/ddd-example-in-ruby-on-rails
spec/modules/cooperation_negotiation/infrastructure/db_contract_repository_spec.rb
Ruby
mit
47
main
3,996
require_relative "../../../rails_helper" module CooperationNegotiation module Infrastructure describe DbContractRepository do subject(:repository) { described_class.new(event_store_write: ::EventStore::Substitute::Write.new) } let(:id) { "00000000-0000-0000-0000-000000000001" } let(:client_id)...
github
pstrzalk/ddd-example-in-ruby-on-rails
https://github.com/pstrzalk/ddd-example-in-ruby-on-rails
spec/modules/cooperation_negotiation/infrastructure/db_contract_spec.rb
Ruby
mit
47
main
265
require_relative "../../../rails_helper" module CooperationNegotiation module Infrastructure describe DbContract do it "can be persisted" do expect { described_class.create }.to change(described_class, :count).by(1) end end end end
github
pstrzalk/ddd-example-in-ruby-on-rails
https://github.com/pstrzalk/ddd-example-in-ruby-on-rails
spec/modules/cooperation_negotiation/application/services/sign_contract_by_client_spec.rb
Ruby
mit
47
main
736
require_relative "../../../../rails_helper" module CooperationNegotiation module Application module Services describe SignContractByClient do let(:client_id) { '00000000-0000-0000-0000-000000000001' } let(:repository) { Domain::ContractRepository.get } describe '.call' do ...
github
pstrzalk/ddd-example-in-ruby-on-rails
https://github.com/pstrzalk/ddd-example-in-ruby-on-rails
spec/modules/cooperation_negotiation/application/services/modify_contract_text_spec.rb
Ruby
mit
47
main
772
require_relative "../../../../rails_helper" module CooperationNegotiation module Application module Services describe ModifyContractText do let(:client_id) { '00000000-0000-0000-0000-000000000001' } let(:repository) { Domain::ContractRepository.get } describe '.call' do i...
github
pstrzalk/ddd-example-in-ruby-on-rails
https://github.com/pstrzalk/ddd-example-in-ruby-on-rails
spec/modules/cooperation_negotiation/application/services/sign_contract_by_company_spec.rb
Ruby
mit
47
main
739
require_relative "../../../../rails_helper" module CooperationNegotiation module Application module Services describe SignContractByCompany do let(:client_id) { '00000000-0000-0000-0000-000000000001' } let(:repository) { Domain::ContractRepository.get } describe '.call' do ...
github
pstrzalk/ddd-example-in-ruby-on-rails
https://github.com/pstrzalk/ddd-example-in-ruby-on-rails
spec/modules/cooperation_negotiation/application/services/prepare_draft_contract_spec.rb
Ruby
mit
47
main
1,120
require_relative "../../../../rails_helper" module CooperationNegotiation module Application module Services describe PrepareDraftContract do let(:identity) { '00000000-0000-0000-0000-000000000000' } let(:client_id) { '00000000-1234-1234-1234-000000000000' } let(:repository) { Domai...
github
pstrzalk/ddd-example-in-ruby-on-rails
https://github.com/pstrzalk/ddd-example-in-ruby-on-rails
config/application.rb
Ruby
mit
47
main
1,179
require_relative "boot" require "rails" # Pick the frameworks you want: require "active_model/railtie" require "active_job/railtie" require "active_record/railtie" require "active_storage/engine" require "action_controller/railtie" require "action_mailer/railtie" require "action_mailbox/engine" require "action_text/en...
github
pstrzalk/ddd-example-in-ruby-on-rails
https://github.com/pstrzalk/ddd-example-in-ruby-on-rails
config/environments/production.rb
Ruby
mit
47
main
3,914
require "active_support/core_ext/integer/time" Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # Code is not reloaded between requests. config.cache_classes = true # Eager load code on boot. This eager loads most of Rails and # your applica...
github
pstrzalk/ddd-example-in-ruby-on-rails
https://github.com/pstrzalk/ddd-example-in-ruby-on-rails
app/modules/commons/domain/with_events.rb
Ruby
mit
47
main
404
module Commons module Domain module WithEvents def dispatch_event(event) self.uncommitted_events ||= [] uncommitted_events << event end def clear_uncommited_events self.uncommitted_events = [] end def uncommited_events uncommitted_events&.dup || [] ...
github
pstrzalk/ddd-example-in-ruby-on-rails
https://github.com/pstrzalk/ddd-example-in-ruby-on-rails
app/modules/cooperation_negotiation/infrastructure/in_memory_contract_repository.rb
Ruby
mit
47
main
1,050
module CooperationNegotiation module Infrastructure class InMemoryContractRepository attr_reader :event_store_write, :memory def initialize(event_store_write: ::EventStore::Write.new) @event_store_write = event_store_write @@memory ||= {} end def of_id(id) @@memor...
github
pstrzalk/ddd-example-in-ruby-on-rails
https://github.com/pstrzalk/ddd-example-in-ruby-on-rails
app/modules/cooperation_negotiation/infrastructure/db_contract_repository.rb
Ruby
mit
47
main
1,867
module CooperationNegotiation module Infrastructure class DbContractRepository attr_reader :event_store_write def initialize(event_store_write: ::EventStore::Write.new) @event_store_write = event_store_write end def of_id(id) db_contract = DbContract.find_by(id: id) ...
github
pstrzalk/ddd-example-in-ruby-on-rails
https://github.com/pstrzalk/ddd-example-in-ruby-on-rails
app/modules/cooperation_negotiation/domain/contract.rb
Ruby
mit
47
main
2,087
module CooperationNegotiation module Domain class Contract include Commons::Domain::WithEvents AlreadySignedError = Class.new(StandardError) AlreadySignedByClientError = Class.new(StandardError) AlreadySignedByCompanyError = Class.new(StandardError) attr_reader :id, :client_id, :te...
github
pstrzalk/ddd-example-in-ruby-on-rails
https://github.com/pstrzalk/ddd-example-in-ruby-on-rails
app/modules/cooperation_negotiation/application/services/modify_contract_text.rb
Ruby
mit
47
main
452
module CooperationNegotiation module Application module Services class ModifyContractText def initialize self.repository = Domain::ContractRepository.get end def call(contract_id:, text:) contract = repository.of_id(contract_id) contract.modify_text(tex...
github
pstrzalk/ddd-example-in-ruby-on-rails
https://github.com/pstrzalk/ddd-example-in-ruby-on-rails
app/modules/cooperation_negotiation/application/services/sign_contract_by_company.rb
Ruby
mit
47
main
446
module CooperationNegotiation module Application module Services class SignContractByCompany def initialize self.repository = Domain::ContractRepository.get end def call(contract_id:) contract = repository.of_id(contract_id) contract.sign_by_company ...
github
pstrzalk/ddd-example-in-ruby-on-rails
https://github.com/pstrzalk/ddd-example-in-ruby-on-rails
app/modules/cooperation_negotiation/application/services/sign_contract_by_client.rb
Ruby
mit
47
main
444
module CooperationNegotiation module Application module Services class SignContractByClient def initialize self.repository = Domain::ContractRepository.get end def call(contract_id:) contract = repository.of_id(contract_id) contract.sign_by_client ...
github
pstrzalk/ddd-example-in-ruby-on-rails
https://github.com/pstrzalk/ddd-example-in-ruby-on-rails
app/modules/cooperation_negotiation/application/services/prepare_draft_contract.rb
Ruby
mit
47
main
855
module CooperationNegotiation module Application module Services class PrepareDraftContract Unauthorized = Class.new(StandardError) def initialize self.repository = Domain::ContractRepository.get end def call(identity:, client_id:) # move this authorizat...
github
pstrzalk/ddd-example-in-ruby-on-rails
https://github.com/pstrzalk/ddd-example-in-ruby-on-rails
app/modules/cooperation_negotiation/application/controllers/contract_controller.rb
Ruby
mit
47
main
335
module CooperationNegotiation module Application module Controllers class ContractController < ::ApplicationController def prepare_draft service = Services::PrepareDraftContract.new service.call(current_identity, params[:client_id]) render :ok end end ...
github
pstrzalk/ddd-example-in-ruby-on-rails
https://github.com/pstrzalk/ddd-example-in-ruby-on-rails
app/modules/authorization/application/api.rb
Ruby
mit
47
main
346
module Authorization module Application class Api def self.identity_in_role?(identity, role_name) return true if identity == '00000000-0000-0000-0000-000000000001' && role_name == 'admin' return true if identity.to_s.match(/\h{8}-(\h{4}-){3}\h{12}/) && role_name == 'client' false ...
github
pstrzalk/ddd-example-in-ruby-on-rails
https://github.com/pstrzalk/ddd-example-in-ruby-on-rails
app/modules/dragon_hunt/domain/party.rb
Ruby
mit
47
main
428
module DragonHunt module Domain class Party attr_reader :id, :client_id def self.assemble(client_id:) new(client_id: client_id) end def initialize(client_id:, id: nil) self.id = id self.client_id = client_id end def ==(other) id == other.id &&...
github
pstrzalk/ddd-example-in-ruby-on-rails
https://github.com/pstrzalk/ddd-example-in-ruby-on-rails
app/modules/dragon_hunt/infrastructure/db_party_repository.rb
Ruby
mit
47
main
720
module DragonHunt module Infrastructure class DbPartyRepository def of_id(id) db_party = DbParty.find_by(id:) return unless db_party Domain::Party.new(id: id, client_id: db_party.client_id) end def of_client_id(client_id) db_party = DbParty.find_by(client_id: cl...
github
pstrzalk/ddd-example-in-ruby-on-rails
https://github.com/pstrzalk/ddd-example-in-ruby-on-rails
app/modules/dragon_hunt/application/handlers/cooperation_negotiation/contract_signed.rb
Ruby
mit
47
main
369
module DragonHunt module Application module Handlers module CooperationNegotiation class ContractSigned def self.call(event) repository = Domain::PartyRepository.get party = Domain::Party.assemble(client_id: event.client_id) repository.save(party) ...
github
pstrzalk/ddd-example-in-ruby-on-rails
https://github.com/pstrzalk/ddd-example-in-ruby-on-rails
app/models/read_models/signed_contract.rb
Ruby
mit
47
main
365
module ReadModels class SignedContract < ApplicationRecord def self.table_name 'read_models_signed_contracts' end def self.save_record(contract_id, attributes = {}) attributes_with_unique_identity = attributes.merge(id: contract_id) upsert( attributes_with_unique_identity, ...
github
pstrzalk/ddd-example-in-ruby-on-rails
https://github.com/pstrzalk/ddd-example-in-ruby-on-rails
app/lib/read_model_handler.rb
Ruby
mit
47
main
835
class ReadModelHandler DEFINITIONS = { 'CooperationNegotiation::Domain::Events::ContractSigned' => [ { model: ReadModels::SignedContract, identity_attribute: 'contract_id', event_read_model_attribute_map: { client_id: 'client_id', text: 'text', time: 'cr...
github
pstrzalk/ddd-example-in-ruby-on-rails
https://github.com/pstrzalk/ddd-example-in-ruby-on-rails
app/lib/event_store.rb
Ruby
mit
47
main
749
module EventStore HANDLERS = { 'CooperationNegotiation::Domain::Events::ContractSigned' => [ 'DragonHunt::Application::Handlers::CooperationNegotiation::ContractSigned', 'ReadModelHandler' ] }.freeze class Write def call(event) handlers = HANDLERS[event.class.name] return unle...
github
pstrzalk/ddd-example-in-ruby-on-rails
https://github.com/pstrzalk/ddd-example-in-ruby-on-rails
app/lib/autowired_repository.rb
Ruby
mit
47
main
1,763
module AutowiredRepository # Solution inspired by Java's Hibernate annotiations, which allow using repositories as domain objects # The domain objects are automatically replaced with implementations on usage # Example may be found in https://github.com/VaughnVernon/IDDD_Samples - implementation of examples from t...
github
jimmyjazz/IDEF0-SVG
https://github.com/jimmyjazz/IDEF0-SVG
lib/idef0/process.rb
Ruby
mit
47
master
3,363
require_relative 'array_set' require_relative 'diagram' module IDEF0 class Process attr_reader :name def self.parse(statements) processes = Hash.new { |hash, name| hash[name] = new(name) } statements.each do |statement| process = processes[statement.subject] case statement.predi...
github
jimmyjazz/IDEF0-SVG
https://github.com/jimmyjazz/IDEF0-SVG
lib/idef0/labels.rb
Ruby
mit
47
master
1,063
module IDEF0 class Label def self.length(text) text.length * 6 end def initialize(text, point) @text = text @point = point end def length self.class.length(@text) end def top_edge @point.y - 20 end def bottom_edge @point.y end def ri...
github
jimmyjazz/IDEF0-SVG
https://github.com/jimmyjazz/IDEF0-SVG
lib/idef0/external_output_line.rb
Ruby
mit
47
master
1,458
require_relative 'point' require_relative 'labels' require_relative 'external_line' module IDEF0 class ExternalOutputLine < ExternalLine def self.make_line(target, source) source.right_side.each_anchor do |anchor| yield(new(source, target, anchor.name)) if target.right_side.expects?(anchor.name) ...
github
jimmyjazz/IDEF0-SVG
https://github.com/jimmyjazz/IDEF0-SVG
lib/idef0/unsatisfied_mechanism_line.rb
Ruby
mit
47
master
339
module IDEF0 class UnsatisfiedMechanismLine < ExternalMechanismLine def self.make_line(source, target) target.bottom_side.each_unattached_anchor do |anchor| source.bottom_side.expects(anchor.name) yield(new(source, target, anchor.name)) end end alias_method :svg_line, :svg_das...
github
jimmyjazz/IDEF0-SVG
https://github.com/jimmyjazz/IDEF0-SVG
lib/idef0/backward_guidance_line.rb
Ruby
mit
47
master
1,929
require_relative 'collection_negation' require_relative 'point' require_relative 'labels' require_relative 'internal_guidance_line' module IDEF0 class BackwardGuidanceLine < InternalGuidanceLine def self.make_line(source, target) return unless source.after?(target) || source == target source.right_si...
github
jimmyjazz/IDEF0-SVG
https://github.com/jimmyjazz/IDEF0-SVG
lib/idef0/point.rb
Ruby
mit
47
master
251
module IDEF0 class Point attr_reader :x, :y def self.origin @origin ||= new(0, 0) end def initialize(x, y) @x = x @y = y end def translate(dx, dy) self.class.new(@x + dx, @y + dy) end end end
github
jimmyjazz/IDEF0-SVG
https://github.com/jimmyjazz/IDEF0-SVG
lib/idef0/diagram.rb
Ruby
mit
47
master
4,258
require_relative 'array_set' require_relative 'positive_number_detection' require_relative 'point' require_relative 'box' require_relative 'process_box' require_relative 'lines' require_relative 'bounds' require_relative 'bounds_extension' module IDEF0 def self.diagram(name) Diagram.new(name).tap do |diagram| ...
github
jimmyjazz/IDEF0-SVG
https://github.com/jimmyjazz/IDEF0-SVG
lib/idef0/backward_mechanism_line.rb
Ruby
mit
47
master
1,896
require_relative 'collection_negation' require_relative 'point' require_relative 'labels' require_relative 'internal_mechanism_line' module IDEF0 class BackwardMechanismLine < InternalMechanismLine def self.make_line(source, target) return unless source.after?(target) || source == target source.right...
github
jimmyjazz/IDEF0-SVG
https://github.com/jimmyjazz/IDEF0-SVG
lib/idef0/unsatisfied_output_line.rb
Ruby
mit
47
master
331
module IDEF0 class UnsatisfiedOutputLine < ExternalOutputLine def self.make_line(target, source) source.right_side.each_unattached_anchor do |anchor| target.right_side.expects(anchor.name) yield(new(source, target, anchor.name)) end end alias_method :svg_line, :svg_dashed_line...
github
jimmyjazz/IDEF0-SVG
https://github.com/jimmyjazz/IDEF0-SVG
lib/idef0/internal_mechanism_line.rb
Ruby
mit
47
master
350
require_relative 'line' module IDEF0 class InternalMechanismLine < Line def attach @source_anchor = source.right_side.attach(self) @target_anchor = target.bottom_side.attach(self) self end def x_vertical x1 + clearance_from(@source.right_side) end def bottom_edge y...
github
jimmyjazz/IDEF0-SVG
https://github.com/jimmyjazz/IDEF0-SVG
lib/idef0/cli.rb
Ruby
mit
47
master
612
require_relative 'statement' require_relative 'process' class Object # TODO Work out what the issue is with inspection and why we used a blanket override. def inspect "<#{self.class.name}:#{object_id}>" end end module IDEF0 module CLI def self.process(io, args) statements = IDEF0::Statement.pars...
github
jimmyjazz/IDEF0-SVG
https://github.com/jimmyjazz/IDEF0-SVG
lib/idef0/process_box.rb
Ruby
mit
47
master
875
require_relative 'box' require_relative 'labels' # TODO: Probably could just call this a ChildBox? module IDEF0 class ProcessBox < Box attr_accessor :sequence def precedence [-right_side.anchor_count, [left_side, top_side, bottom_side].map(&:anchor_count).reduce(&:+)] end def width [Lab...
github
jimmyjazz/IDEF0-SVG
https://github.com/jimmyjazz/IDEF0-SVG
lib/idef0/unsatisfied_input_line.rb
Ruby
mit
47
master
327
module IDEF0 class UnsatisfiedInputLine < ExternalInputLine def self.make_line(source, target) target.left_side.each_unattached_anchor do |anchor| source.left_side.expects(anchor.name) yield(new(source, target, anchor.name)) end end alias_method :svg_line, :svg_dashed_line e...
github
jimmyjazz/IDEF0-SVG
https://github.com/jimmyjazz/IDEF0-SVG
lib/idef0/bounds_extension.rb
Ruby
mit
47
master
436
module IDEF0 class BoundsExtension attr_reader :north, :south, :east, :west def initialize @north = @south = @east = @west = 0 end def north=(value) @north = value if value > @north end def south=(value) @south = value if value > @south end def east=(value) ...
github
jimmyjazz/IDEF0-SVG
https://github.com/jimmyjazz/IDEF0-SVG
lib/idef0/array_set.rb
Ruby
mit
47
master
2,055
require 'forwardable' # A custom set that is ordered to give us a chance at manipulating the layout. module IDEF0 class ArraySet extend Forwardable def initialize(items = []) boom! unless items.is_a?(Array) @items = items end def_delegators :@items, :index, :[], :count, :each, :include?...
github
jimmyjazz/IDEF0-SVG
https://github.com/jimmyjazz/IDEF0-SVG
lib/idef0/line.rb
Ruby
mit
47
master
2,274
require_relative 'point' require_relative 'labels' module IDEF0 class Line attr_reader :source, :target, :name attr_reader :source_anchor, :target_anchor def initialize(source, target, name) @source = source @target = target @name = name @clearance = {} end def backward?...
github
jimmyjazz/IDEF0-SVG
https://github.com/jimmyjazz/IDEF0-SVG
lib/idef0/external_input_line.rb
Ruby
mit
47
master
1,257
require_relative 'point' require_relative 'labels' require_relative 'external_line' module IDEF0 class ExternalInputLine < ExternalLine def self.make_line(source, target) source.left_side.each_anchor do |anchor| yield(new(source, target, anchor.name)) if target.left_side.expects?(anchor.name) ...
github
jimmyjazz/IDEF0-SVG
https://github.com/jimmyjazz/IDEF0-SVG
lib/idef0/lines.rb
Ruby
mit
47
master
999
require_relative 'forward_input_line' require_relative 'backward_input_line' require_relative 'forward_guidance_line' require_relative 'backward_guidance_line' require_relative 'forward_mechanism_line' require_relative 'backward_mechanism_line' require_relative 'external_input_line' require_relative 'external_output_li...