repo
stringlengths
5
92
file_url
stringlengths
80
287
file_path
stringlengths
5
197
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 15:37:27
2026-01-04 17:58:21
truncated
bool
2 classes
magnusvk/counter_culture
https://github.com/magnusvk/counter_culture/blob/494e0ec01d1cd61dfed59e9c40e95902538fe981/spec/models/city.rb
spec/models/city.rb
class City < ActiveRecord::Base belongs_to :prefecture scope :big, -> { where('population > ?', 100000) } scope :small, -> { where('population <= ?', 100000) } counter_culture( :prefecture, column_name: ->(model) { model.big? ? :big_cities_count : nil }, column_names: { City.big => :big_cities_cou...
ruby
MIT
494e0ec01d1cd61dfed59e9c40e95902538fe981
2026-01-04T15:58:21.279457Z
false
magnusvk/counter_culture
https://github.com/magnusvk/counter_culture/blob/494e0ec01d1cd61dfed59e9c40e95902538fe981/spec/models/transaction.rb
spec/models/transaction.rb
class Transaction < ActiveRecord::Base belongs_to :person counter_culture [:person], :column_name => proc {|model| model.earns_money? ? 'money_earned_total' : 'money_spent_total' }, :column_names => { ["transactions.monetary_value > 0"] => 'money_earned_total', ["transactions.monetary_v...
ruby
MIT
494e0ec01d1cd61dfed59e9c40e95902538fe981
2026-01-04T15:58:21.279457Z
false
magnusvk/counter_culture
https://github.com/magnusvk/counter_culture/blob/494e0ec01d1cd61dfed59e9c40e95902538fe981/spec/models/category.rb
spec/models/category.rb
class Category < ActiveRecord::Base has_many :products end
ruby
MIT
494e0ec01d1cd61dfed59e9c40e95902538fe981
2026-01-04T15:58:21.279457Z
false
magnusvk/counter_culture
https://github.com/magnusvk/counter_culture/blob/494e0ec01d1cd61dfed59e9c40e95902538fe981/spec/models/conditional_main.rb
spec/models/conditional_main.rb
class ConditionalMain < ActiveRecord::Base has_many :conditional_dependents end
ruby
MIT
494e0ec01d1cd61dfed59e9c40e95902538fe981
2026-01-04T15:58:21.279457Z
false
magnusvk/counter_culture
https://github.com/magnusvk/counter_culture/blob/494e0ec01d1cd61dfed59e9c40e95902538fe981/spec/models/has_non_pk_id.rb
spec/models/has_non_pk_id.rb
class HasNonPkId < ActiveRecord::Base self.primary_key = :id has_many :users end
ruby
MIT
494e0ec01d1cd61dfed59e9c40e95902538fe981
2026-01-04T15:58:21.279457Z
false
magnusvk/counter_culture
https://github.com/magnusvk/counter_culture/blob/494e0ec01d1cd61dfed59e9c40e95902538fe981/spec/models/composite_group_user.rb
spec/models/composite_group_user.rb
class CompositeGroupUser < ActiveRecord::Base belongs_to :composite_group, primary_key: [:id, :secondary_id], foreign_key: [:composite_group_id, :secondary_id] belongs_to :composite_user counter_culture :composite_group, column_name: 'composite_users_count' counter_culture :composite_group, column_name...
ruby
MIT
494e0ec01d1cd61dfed59e9c40e95902538fe981
2026-01-04T15:58:21.279457Z
false
magnusvk/counter_culture
https://github.com/magnusvk/counter_culture/blob/494e0ec01d1cd61dfed59e9c40e95902538fe981/spec/models/article.rb
spec/models/article.rb
class Article < ActiveRecord::Base belongs_to :article_group, :foreign_key => :article_group_id counter_culture :article_group, :column_name => :articles_count attr_reader :title_en, :title_ja after_initialize do @title_en = title['en'] @title_ja = title['ja'] @custom_changes = { title_...
ruby
MIT
494e0ec01d1cd61dfed59e9c40e95902538fe981
2026-01-04T15:58:21.279457Z
false
magnusvk/counter_culture
https://github.com/magnusvk/counter_culture/blob/494e0ec01d1cd61dfed59e9c40e95902538fe981/spec/models/comment.rb
spec/models/comment.rb
class Comment < ActiveRecord::Base belongs_to :commentable, polymorphic: true has_many :comments, as: :commentable, inverse_of: :commentable counter_culture :commentable, :column_name => :comments_count end
ruby
MIT
494e0ec01d1cd61dfed59e9c40e95902538fe981
2026-01-04T15:58:21.279457Z
false
magnusvk/counter_culture
https://github.com/magnusvk/counter_culture/blob/494e0ec01d1cd61dfed59e9c40e95902538fe981/spec/models/purchase_order_item.rb
spec/models/purchase_order_item.rb
class PurchaseOrderItem < ActiveRecord::Base belongs_to :purchase_order counter_culture :purchase_order, column_name: 'total_amount', delta_column: 'amount' end
ruby
MIT
494e0ec01d1cd61dfed59e9c40e95902538fe981
2026-01-04T15:58:21.279457Z
false
magnusvk/counter_culture
https://github.com/magnusvk/counter_culture/blob/494e0ec01d1cd61dfed59e9c40e95902538fe981/spec/models/has_string_id.rb
spec/models/has_string_id.rb
class HasStringId < ActiveRecord::Base self.primary_key = :id has_many :users end
ruby
MIT
494e0ec01d1cd61dfed59e9c40e95902538fe981
2026-01-04T15:58:21.279457Z
false
magnusvk/counter_culture
https://github.com/magnusvk/counter_culture/blob/494e0ec01d1cd61dfed59e9c40e95902538fe981/spec/models/simple_main.rb
spec/models/simple_main.rb
class SimpleMain < ActiveRecord::Base has_many :simple_dependents if PapertrailSupport.supported_here? has_paper_trail end end
ruby
MIT
494e0ec01d1cd61dfed59e9c40e95902538fe981
2026-01-04T15:58:21.279457Z
false
magnusvk/counter_culture
https://github.com/magnusvk/counter_culture/blob/494e0ec01d1cd61dfed59e9c40e95902538fe981/spec/models/conversation.rb
spec/models/conversation.rb
class Conversation < ActiveRecord::Base belongs_to :candidate delegate( :candidate_profile, to: :candidate ) counter_culture [:candidate, :candidate_profile] end
ruby
MIT
494e0ec01d1cd61dfed59e9c40e95902538fe981
2026-01-04T15:58:21.279457Z
false
magnusvk/counter_culture
https://github.com/magnusvk/counter_culture/blob/494e0ec01d1cd61dfed59e9c40e95902538fe981/spec/models/soft_delete_discard.rb
spec/models/soft_delete_discard.rb
require 'discard' class SoftDeleteDiscard < ActiveRecord::Base include Discard::Model if defined?(Discard::Model) belongs_to :company counter_culture :company counter_culture :company, column_name: 'soft_delete_discard_values_sum', delta_column: 'value' end
ruby
MIT
494e0ec01d1cd61dfed59e9c40e95902538fe981
2026-01-04T15:58:21.279457Z
false
magnusvk/counter_culture
https://github.com/magnusvk/counter_culture/blob/494e0ec01d1cd61dfed59e9c40e95902538fe981/spec/models/post.rb
spec/models/post.rb
class Post < ActiveRecord::Base self.primary_key = :post_id belongs_to :subcateg, :foreign_key => :fk_subcat_id has_many :post_comments has_many :post_likes counter_culture :subcateg, :column_name => :posts_count counter_culture :subcateg, :column_name => :posts_after_commit_count, :execute_after_comm...
ruby
MIT
494e0ec01d1cd61dfed59e9c40e95902538fe981
2026-01-04T15:58:21.279457Z
false
magnusvk/counter_culture
https://github.com/magnusvk/counter_culture/blob/494e0ec01d1cd61dfed59e9c40e95902538fe981/spec/models/another_post.rb
spec/models/another_post.rb
class AnotherPost < ActiveRecord::Base has_many :comments, class_name: 'AnotherPostComment', foreign_key: 'another_post_id', primary_key: 'another_id' before_save :assign_another_id, :if => :new_record? private def assign_another_id loop do self.another_id = Random.rand(65535) break unless sel...
ruby
MIT
494e0ec01d1cd61dfed59e9c40e95902538fe981
2026-01-04T15:58:21.279457Z
false
magnusvk/counter_culture
https://github.com/magnusvk/counter_culture/blob/494e0ec01d1cd61dfed59e9c40e95902538fe981/spec/models/product.rb
spec/models/product.rb
class Product < ActiveRecord::Base belongs_to :category counter_culture :category, :foreign_key_values => lambda { |foreign_key_value| if foreign_key_value.present? Category.pluck(:id) else nil end } if PapertrailSupport.supported_here? has_paper_trail end end
ruby
MIT
494e0ec01d1cd61dfed59e9c40e95902538fe981
2026-01-04T15:58:21.279457Z
false
magnusvk/counter_culture
https://github.com/magnusvk/counter_culture/blob/494e0ec01d1cd61dfed59e9c40e95902538fe981/spec/models/simple_dependent.rb
spec/models/simple_dependent.rb
class SimpleDependent < ActiveRecord::Base belongs_to :simple_main counter_culture :simple_main, with_papertrail: PapertrailSupport.supported_here? end
ruby
MIT
494e0ec01d1cd61dfed59e9c40e95902538fe981
2026-01-04T15:58:21.279457Z
false
magnusvk/counter_culture
https://github.com/magnusvk/counter_culture/blob/494e0ec01d1cd61dfed59e9c40e95902538fe981/spec/models/candidate_profile.rb
spec/models/candidate_profile.rb
class CandidateProfile < ActiveRecord::Base belongs_to :candidate end
ruby
MIT
494e0ec01d1cd61dfed59e9c40e95902538fe981
2026-01-04T15:58:21.279457Z
false
magnusvk/counter_culture
https://github.com/magnusvk/counter_culture/blob/494e0ec01d1cd61dfed59e9c40e95902538fe981/spec/models/industry.rb
spec/models/industry.rb
class Industry < ActiveRecord::Base end
ruby
MIT
494e0ec01d1cd61dfed59e9c40e95902538fe981
2026-01-04T15:58:21.279457Z
false
magnusvk/counter_culture
https://github.com/magnusvk/counter_culture/blob/494e0ec01d1cd61dfed59e9c40e95902538fe981/spec/models/composite_group.rb
spec/models/composite_group.rb
class CompositeGroup < ActiveRecord::Base has_many :composite_group_users, primary_key: [:id, :secondary_id], foreign_key: [:composite_group_id, :secondary_id] has_many :composite_users, through: :composite_group_users if PapertrailSupport.supported_here? has_paper_trail end end
ruby
MIT
494e0ec01d1cd61dfed59e9c40e95902538fe981
2026-01-04T15:58:21.279457Z
false
magnusvk/counter_culture
https://github.com/magnusvk/counter_culture/blob/494e0ec01d1cd61dfed59e9c40e95902538fe981/spec/models/subcateg.rb
spec/models/subcateg.rb
class Subcateg < ActiveRecord::Base SUBCAT_1 = 0 SUBCAT_2 = 1 self.primary_key = :subcat_id if PapertrailSupport.supported_here? has_paper_trail end has_many :posts belongs_to :categ, :foreign_key => :fk_cat_id def subcat_id # required for Rails 3.2 compatibility read_attribute(:subcat_i...
ruby
MIT
494e0ec01d1cd61dfed59e9c40e95902538fe981
2026-01-04T15:58:21.279457Z
false
magnusvk/counter_culture
https://github.com/magnusvk/counter_culture/blob/494e0ec01d1cd61dfed59e9c40e95902538fe981/spec/models/purchase_order.rb
spec/models/purchase_order.rb
class PurchaseOrder < ActiveRecord::Base has_many :purchase_order_items, dependent: :destroy end
ruby
MIT
494e0ec01d1cd61dfed59e9c40e95902538fe981
2026-01-04T15:58:21.279457Z
false
magnusvk/counter_culture
https://github.com/magnusvk/counter_culture/blob/494e0ec01d1cd61dfed59e9c40e95902538fe981/spec/models/group_item.rb
spec/models/group_item.rb
class GroupItem < ActiveRecord::Base counter_culture %i[sub_group group] belongs_to :sub_group, foreign_key: 'sub_group_uuid' end
ruby
MIT
494e0ec01d1cd61dfed59e9c40e95902538fe981
2026-01-04T15:58:21.279457Z
false
magnusvk/counter_culture
https://github.com/magnusvk/counter_culture/blob/494e0ec01d1cd61dfed59e9c40e95902538fe981/spec/models/admin_user.rb
spec/models/admin_user.rb
# frozen_string_literal: true class AdminUser < User end
ruby
MIT
494e0ec01d1cd61dfed59e9c40e95902538fe981
2026-01-04T15:58:21.279457Z
false
magnusvk/counter_culture
https://github.com/magnusvk/counter_culture/blob/494e0ec01d1cd61dfed59e9c40e95902538fe981/spec/models/prefecture.rb
spec/models/prefecture.rb
class Prefecture < ActiveRecord::Base has_many :cities end
ruby
MIT
494e0ec01d1cd61dfed59e9c40e95902538fe981
2026-01-04T15:58:21.279457Z
false
magnusvk/counter_culture
https://github.com/magnusvk/counter_culture/blob/494e0ec01d1cd61dfed59e9c40e95902538fe981/spec/models/person.rb
spec/models/person.rb
class Person < ActiveRecord::Base has_many :transactions end
ruby
MIT
494e0ec01d1cd61dfed59e9c40e95902538fe981
2026-01-04T15:58:21.279457Z
false
magnusvk/counter_culture
https://github.com/magnusvk/counter_culture/blob/494e0ec01d1cd61dfed59e9c40e95902538fe981/spec/models/post_comment.rb
spec/models/post_comment.rb
class PostComment < ActiveRecord::Base self.primary_key = :post_id belongs_to :post, :foreign_key => 'post_id' counter_culture :post, :column_name => :comments_count end
ruby
MIT
494e0ec01d1cd61dfed59e9c40e95902538fe981
2026-01-04T15:58:21.279457Z
false
magnusvk/counter_culture
https://github.com/magnusvk/counter_culture/blob/494e0ec01d1cd61dfed59e9c40e95902538fe981/spec/models/soft_delete_paranoia.rb
spec/models/soft_delete_paranoia.rb
require 'paranoia' class SoftDeleteParanoia < ActiveRecord::Base acts_as_paranoid if respond_to?(:acts_as_paranoid) belongs_to :company counter_culture :company counter_culture :company, column_name: 'soft_delete_paranoia_values_sum', delta_column: 'value' end
ruby
MIT
494e0ec01d1cd61dfed59e9c40e95902538fe981
2026-01-04T15:58:21.279457Z
false
magnusvk/counter_culture
https://github.com/magnusvk/counter_culture/blob/494e0ec01d1cd61dfed59e9c40e95902538fe981/spec/models/another_post_comment.rb
spec/models/another_post_comment.rb
class AnotherPostComment < ActiveRecord::Base belongs_to :post, class_name: 'AnotherPost', foreign_key: 'another_post_id', primary_key: 'another_id' counter_culture :post end
ruby
MIT
494e0ec01d1cd61dfed59e9c40e95902538fe981
2026-01-04T15:58:21.279457Z
false
magnusvk/counter_culture
https://github.com/magnusvk/counter_culture/blob/494e0ec01d1cd61dfed59e9c40e95902538fe981/spec/models/company.rb
spec/models/company.rb
class Company < ActiveRecord::Base belongs_to :industry has_many :managers, :foreign_key => :manages_company_id belongs_to :parent, :class_name => 'Company', :foreign_key => 'parent_id' has_many :children, :class_name => 'Company', :foreign_key => 'parent_id' counter_culture :parent, :column_name => :child...
ruby
MIT
494e0ec01d1cd61dfed59e9c40e95902538fe981
2026-01-04T15:58:21.279457Z
false
magnusvk/counter_culture
https://github.com/magnusvk/counter_culture/blob/494e0ec01d1cd61dfed59e9c40e95902538fe981/spec/models/user.rb
spec/models/user.rb
class User < ActiveRecord::Base belongs_to :employer belongs_to :manages_company, :class_name => "Company" counter_culture :manages_company, :column_name => "managers_count" belongs_to :has_string_id counter_culture :has_string_id belongs_to :has_non_pk_id counter_culture :has_non_pk_id has_many :re...
ruby
MIT
494e0ec01d1cd61dfed59e9c40e95902538fe981
2026-01-04T15:58:21.279457Z
false
magnusvk/counter_culture
https://github.com/magnusvk/counter_culture/blob/494e0ec01d1cd61dfed59e9c40e95902538fe981/spec/models/with_module/model1.rb
spec/models/with_module/model1.rb
module WithModule class Model1 < ActiveRecord::Base self.table_name_prefix = 'with_module_' belongs_to :model2 counter_culture :model2 end end
ruby
MIT
494e0ec01d1cd61dfed59e9c40e95902538fe981
2026-01-04T15:58:21.279457Z
false
magnusvk/counter_culture
https://github.com/magnusvk/counter_culture/blob/494e0ec01d1cd61dfed59e9c40e95902538fe981/spec/models/with_module/model2.rb
spec/models/with_module/model2.rb
module WithModule class Model2 < ActiveRecord::Base self.table_name_prefix = 'with_module_' has_many :model1s end end
ruby
MIT
494e0ec01d1cd61dfed59e9c40e95902538fe981
2026-01-04T15:58:21.279457Z
false
magnusvk/counter_culture
https://github.com/magnusvk/counter_culture/blob/494e0ec01d1cd61dfed59e9c40e95902538fe981/lib/counter_culture.rb
lib/counter_culture.rb
require 'active_support/concern' require 'active_support/lazy_load_hooks' require 'counter_culture/version' require 'counter_culture/extensions' require 'counter_culture/configuration' require 'counter_culture/counter' require 'counter_culture/reconciler' require 'counter_culture/skip_updates' module CounterCulture ...
ruby
MIT
494e0ec01d1cd61dfed59e9c40e95902538fe981
2026-01-04T15:58:21.279457Z
false
magnusvk/counter_culture
https://github.com/magnusvk/counter_culture/blob/494e0ec01d1cd61dfed59e9c40e95902538fe981/lib/counter_culture/version.rb
lib/counter_culture/version.rb
module CounterCulture VERSION = '3.11.4'.freeze end
ruby
MIT
494e0ec01d1cd61dfed59e9c40e95902538fe981
2026-01-04T15:58:21.279457Z
false
magnusvk/counter_culture
https://github.com/magnusvk/counter_culture/blob/494e0ec01d1cd61dfed59e9c40e95902538fe981/lib/counter_culture/extensions.rb
lib/counter_culture/extensions.rb
module CounterCulture module Extensions extend ActiveSupport::Concern module ClassMethods # this holds all configuration data def after_commit_counter_cache config = @after_commit_counter_cache || [] if superclass.respond_to?(:after_commit_counter_cache) && superclass.after_commit...
ruby
MIT
494e0ec01d1cd61dfed59e9c40e95902538fe981
2026-01-04T15:58:21.279457Z
false
magnusvk/counter_culture
https://github.com/magnusvk/counter_culture/blob/494e0ec01d1cd61dfed59e9c40e95902538fe981/lib/counter_culture/configuration.rb
lib/counter_culture/configuration.rb
module CounterCulture def self.configuration @configuration ||= Configuration.new end def self.configure yield(configuration) end def self.reset_configuration @configuration = Configuration.new end def self.supports_composite_keys? Gem::Requirement.new('>= 7.2.0').satisfied_by?(ActiveRe...
ruby
MIT
494e0ec01d1cd61dfed59e9c40e95902538fe981
2026-01-04T15:58:21.279457Z
false
magnusvk/counter_culture
https://github.com/magnusvk/counter_culture/blob/494e0ec01d1cd61dfed59e9c40e95902538fe981/lib/counter_culture/counter.rb
lib/counter_culture/counter.rb
require_relative './with_connection' module CounterCulture class Counter CONFIG_OPTIONS = [ :column_names, :counter_cache_name, :delta_column, :foreign_key_values, :touch, :delta_magnitude, :execute_after_commit ] ACTIVE_RECORD_VERSION = Gem.loaded_specs["activerecord"].version attr_reader :model, :rela...
ruby
MIT
494e0ec01d1cd61dfed59e9c40e95902538fe981
2026-01-04T15:58:21.279457Z
false
magnusvk/counter_culture
https://github.com/magnusvk/counter_culture/blob/494e0ec01d1cd61dfed59e9c40e95902538fe981/lib/counter_culture/skip_updates.rb
lib/counter_culture/skip_updates.rb
module CounterCulture module SkipUpdates private # called by after_create callback def _update_counts_after_create unless Array(Thread.current[:skip_counter_culture_updates]).include?(self.class) super end end # called by after_destroy callback def _update_counts_after_de...
ruby
MIT
494e0ec01d1cd61dfed59e9c40e95902538fe981
2026-01-04T15:58:21.279457Z
false
magnusvk/counter_culture
https://github.com/magnusvk/counter_culture/blob/494e0ec01d1cd61dfed59e9c40e95902538fe981/lib/counter_culture/with_connection.rb
lib/counter_culture/with_connection.rb
module CounterCulture class WithConnection def initialize(recipient) @recipient = recipient end attr_reader :recipient def call(reading: false) if rails_7_1_or_greater? use_read_replica = CounterCulture.configuration.use_read_replica && reading role = use_read_replica ? :...
ruby
MIT
494e0ec01d1cd61dfed59e9c40e95902538fe981
2026-01-04T15:58:21.279457Z
false
magnusvk/counter_culture
https://github.com/magnusvk/counter_culture/blob/494e0ec01d1cd61dfed59e9c40e95902538fe981/lib/counter_culture/reconciler.rb
lib/counter_culture/reconciler.rb
require 'active_support/core_ext/module/delegation' require 'active_support/core_ext/module/attribute_accessors' require_relative './with_connection' module CounterCulture class Reconciler ACTIVE_RECORD_VERSION = Gem.loaded_specs["activerecord"].version attr_reader :counter, :options, :changes delegat...
ruby
MIT
494e0ec01d1cd61dfed59e9c40e95902538fe981
2026-01-04T15:58:21.279457Z
false
magnusvk/counter_culture
https://github.com/magnusvk/counter_culture/blob/494e0ec01d1cd61dfed59e9c40e95902538fe981/lib/generators/counter_culture_generator.rb
lib/generators/counter_culture_generator.rb
require 'rails/generators/active_record' class CounterCultureGenerator < ActiveRecord::Generators::Base desc "Create a migration that adds counter-cache columns to a model" argument :counter_cache_columns, :required => true, :type => :array, :desc => "The names of the counter cache columns to add", :bann...
ruby
MIT
494e0ec01d1cd61dfed59e9c40e95902538fe981
2026-01-04T15:58:21.279457Z
false
AaronLasseigne/active_interaction
https://github.com/AaronLasseigne/active_interaction/blob/97667c8283a4479c7ffc021be31f168d17b20b72/spec/spec_helper.rb
spec/spec_helper.rb
require 'i18n' I18n.config.enforce_available_locales = true if I18n.config.respond_to?(:enforce_available_locales) require 'active_interaction' require 'active_record' Dir['./spec/support/**/*.rb'].sort.each { |f| require f } RSpec.configure do |config| config.run_all_when_everything_filtered = true config.filte...
ruby
MIT
97667c8283a4479c7ffc021be31f168d17b20b72
2026-01-04T15:57:54.678054Z
false
AaronLasseigne/active_interaction
https://github.com/AaronLasseigne/active_interaction/blob/97667c8283a4479c7ffc021be31f168d17b20b72/spec/support/interactions.rb
spec/support/interactions.rb
TestInteraction = Class.new(ActiveInteraction::Base) do def self.name SecureRandom.hex end def execute inputs end end RSpec.shared_context 'interactions' do let(:inputs) { {} } let(:outcome) { described_class.run(inputs) } let(:result) { outcome.result } end RSpec.shared_examples_for 'an intera...
ruby
MIT
97667c8283a4479c7ffc021be31f168d17b20b72
2026-01-04T15:57:54.678054Z
false
AaronLasseigne/active_interaction
https://github.com/AaronLasseigne/active_interaction/blob/97667c8283a4479c7ffc021be31f168d17b20b72/spec/support/concerns.rb
spec/support/concerns.rb
RSpec.shared_context 'concerns' do |concern| subject(:instance) { klass.new } let(:klass) do Class.new do include concern def self.name SecureRandom.hex end end end end
ruby
MIT
97667c8283a4479c7ffc021be31f168d17b20b72
2026-01-04T15:57:54.678054Z
false
AaronLasseigne/active_interaction
https://github.com/AaronLasseigne/active_interaction/blob/97667c8283a4479c7ffc021be31f168d17b20b72/spec/support/filters.rb
spec/support/filters.rb
RSpec.shared_context 'filters' do subject(:filter) { described_class.new(name, options, &block) } let(:block) { nil } let(:name) { SecureRandom.hex.to_sym } let(:options) { {} } shared_context 'optional' do before do options[:default] = nil end end shared_context 'required' do before ...
ruby
MIT
97667c8283a4479c7ffc021be31f168d17b20b72
2026-01-04T15:57:54.678054Z
false
AaronLasseigne/active_interaction
https://github.com/AaronLasseigne/active_interaction/blob/97667c8283a4479c7ffc021be31f168d17b20b72/spec/active_interaction/grouped_input_spec.rb
spec/active_interaction/grouped_input_spec.rb
RSpec.describe ActiveInteraction::GroupedInput do describe '.new' do it 'adds all values to the object' do grouped_input = described_class.new('1' => 1, '2' => 2) expect(grouped_input['1']).to be 1 expect(grouped_input['2']).to be 2 end end describe '#[]' do it 'returns nil if the ...
ruby
MIT
97667c8283a4479c7ffc021be31f168d17b20b72
2026-01-04T15:57:54.678054Z
false
AaronLasseigne/active_interaction
https://github.com/AaronLasseigne/active_interaction/blob/97667c8283a4479c7ffc021be31f168d17b20b72/spec/active_interaction/array_input_spec.rb
spec/active_interaction/array_input_spec.rb
RSpec.describe ActiveInteraction::ArrayInput do subject(:input) do described_class.new(filter, value: value, error: error, index_errors: index_errors, children: children ) end let(:filter) do ActiveInteraction::ArrayFilter.new(:a, &block) end let(:block) { proc { integer }...
ruby
MIT
97667c8283a4479c7ffc021be31f168d17b20b72
2026-01-04T15:57:54.678054Z
false
AaronLasseigne/active_interaction
https://github.com/AaronLasseigne/active_interaction/blob/97667c8283a4479c7ffc021be31f168d17b20b72/spec/active_interaction/i18n_spec.rb
spec/active_interaction/i18n_spec.rb
RSpec.describe ActiveInteraction do context 'I18n.load_path' do it 'contains localization file paths' do expect(I18n.load_path) .to include a_string_ending_with('active_interaction/locale/en.yml') end end end I18nInteraction = Class.new(TestInteraction) do hash :a do hash :x end end ...
ruby
MIT
97667c8283a4479c7ffc021be31f168d17b20b72
2026-01-04T15:57:54.678054Z
false
AaronLasseigne/active_interaction
https://github.com/AaronLasseigne/active_interaction/blob/97667c8283a4479c7ffc021be31f168d17b20b72/spec/active_interaction/filter_spec.rb
spec/active_interaction/filter_spec.rb
RSpec.describe ActiveInteraction::Filter, :filter do include_context 'filters' describe '#database_column_type' do it 'returns `:string`' do expect(filter.database_column_type).to be :string end end context 'with an unregistered subclass' do let(:klass) { Class.new(described_class) } de...
ruby
MIT
97667c8283a4479c7ffc021be31f168d17b20b72
2026-01-04T15:57:54.678054Z
false
AaronLasseigne/active_interaction
https://github.com/AaronLasseigne/active_interaction/blob/97667c8283a4479c7ffc021be31f168d17b20b72/spec/active_interaction/inputs_spec.rb
spec/active_interaction/inputs_spec.rb
RSpec.describe ActiveInteraction::Inputs do subject(:inputs) { described_class.new(args, base_class.new) } let(:args) { {} } let(:base_class) { ActiveInteraction::Base } describe '.reserved?(name)' do it 'returns true for anything starting with "_interaction_"' do expect(described_class).to be_reser...
ruby
MIT
97667c8283a4479c7ffc021be31f168d17b20b72
2026-01-04T15:57:54.678054Z
false
AaronLasseigne/active_interaction
https://github.com/AaronLasseigne/active_interaction/blob/97667c8283a4479c7ffc021be31f168d17b20b72/spec/active_interaction/base_spec.rb
spec/active_interaction/base_spec.rb
require 'action_controller' require 'active_support/core_ext/kernel/reporting' InteractionWithFilter = Class.new(TestInteraction) do float :thing end InteractionWithDateFilter = Class.new(TestInteraction) do date :thing end AddInteraction = Class.new(TestInteraction) do float :x, :y def execute x + y ...
ruby
MIT
97667c8283a4479c7ffc021be31f168d17b20b72
2026-01-04T15:57:54.678054Z
false
AaronLasseigne/active_interaction
https://github.com/AaronLasseigne/active_interaction/blob/97667c8283a4479c7ffc021be31f168d17b20b72/spec/active_interaction/errors_spec.rb
spec/active_interaction/errors_spec.rb
require 'active_record' require 'sqlite3' ActiveRecord::Base.establish_connection( adapter: 'sqlite3', database: ':memory:' ) RSpec.describe ActiveInteraction::Errors do subject(:errors) { described_class.new(klass.new) } let(:klass) do Class.new(ActiveInteraction::Base) do string :attribute, defua...
ruby
MIT
97667c8283a4479c7ffc021be31f168d17b20b72
2026-01-04T15:57:54.678054Z
false
AaronLasseigne/active_interaction
https://github.com/AaronLasseigne/active_interaction/blob/97667c8283a4479c7ffc021be31f168d17b20b72/spec/active_interaction/validation_spec.rb
spec/active_interaction/validation_spec.rb
RSpec.describe ActiveInteraction::Validation do describe '.validate(context, filters, inputs)' do let(:inputs) { {} } let(:filter) { ActiveInteraction::Filter.new(:name, {}) } let(:interaction) do name = filter.name klass = Class.new(ActiveInteraction::Base) { attr_writer(name) } klass.f...
ruby
MIT
97667c8283a4479c7ffc021be31f168d17b20b72
2026-01-04T15:57:54.678054Z
false
AaronLasseigne/active_interaction
https://github.com/AaronLasseigne/active_interaction/blob/97667c8283a4479c7ffc021be31f168d17b20b72/spec/active_interaction/hash_input_spec.rb
spec/active_interaction/hash_input_spec.rb
RSpec.describe ActiveInteraction::HashInput do subject(:input) do described_class.new(filter, value: value, error: error, children: children ) end let(:filter) do ActiveInteraction::HashFilter.new(:h, &block) end let(:block) { proc { integer :i } } let(:value) { nil } let(:e...
ruby
MIT
97667c8283a4479c7ffc021be31f168d17b20b72
2026-01-04T15:57:54.678054Z
false
AaronLasseigne/active_interaction
https://github.com/AaronLasseigne/active_interaction/blob/97667c8283a4479c7ffc021be31f168d17b20b72/spec/active_interaction/concerns/active_modelable_spec.rb
spec/active_interaction/concerns/active_modelable_spec.rb
RSpec.shared_examples_for 'ActiveModel' do it 'includes ActiveModel::Conversion' do expect(subject).to be_a ActiveModel::Conversion end it 'includes ActiveModel::Validations' do expect(subject).to be_a ActiveModel::Validations end it 'extends ActiveModel::Naming' do expect(subject.class).to be_a...
ruby
MIT
97667c8283a4479c7ffc021be31f168d17b20b72
2026-01-04T15:57:54.678054Z
false
AaronLasseigne/active_interaction
https://github.com/AaronLasseigne/active_interaction/blob/97667c8283a4479c7ffc021be31f168d17b20b72/spec/active_interaction/concerns/runnable_spec.rb
spec/active_interaction/concerns/runnable_spec.rb
RSpec.describe ActiveInteraction::Runnable do include_context 'concerns', described_class class WrappableFailingInteraction # rubocop:disable Lint/ConstantDefinitionInBlock include ActiveInteraction::Runnable def execute errors.add(:base) end end shared_context 'with an error' do before...
ruby
MIT
97667c8283a4479c7ffc021be31f168d17b20b72
2026-01-04T15:57:54.678054Z
false
AaronLasseigne/active_interaction
https://github.com/AaronLasseigne/active_interaction/blob/97667c8283a4479c7ffc021be31f168d17b20b72/spec/active_interaction/concerns/missable_spec.rb
spec/active_interaction/concerns/missable_spec.rb
RSpec.describe ActiveInteraction::Missable do include_context 'concerns', described_class describe '#respond_to?(slug, include_all = false)' do context 'with invalid slug' do let(:slug) { :slug } it 'returns false' do expect(instance).to_not respond_to(slug) end end context ...
ruby
MIT
97667c8283a4479c7ffc021be31f168d17b20b72
2026-01-04T15:57:54.678054Z
false
AaronLasseigne/active_interaction
https://github.com/AaronLasseigne/active_interaction/blob/97667c8283a4479c7ffc021be31f168d17b20b72/spec/active_interaction/concerns/active_recordable_spec.rb
spec/active_interaction/concerns/active_recordable_spec.rb
InteractionWithFloatFilter = Class.new(TestInteraction) do float :thing end RSpec.describe ActiveInteraction::ActiveRecordable do include_context 'interactions' let(:described_class) { InteractionWithFloatFilter } describe '#column_for_attribute(name)' do let(:column) { outcome.column_for_attribute(name)...
ruby
MIT
97667c8283a4479c7ffc021be31f168d17b20b72
2026-01-04T15:57:54.678054Z
false
AaronLasseigne/active_interaction
https://github.com/AaronLasseigne/active_interaction/blob/97667c8283a4479c7ffc021be31f168d17b20b72/spec/active_interaction/concerns/hashable_spec.rb
spec/active_interaction/concerns/hashable_spec.rb
RSpec.describe ActiveInteraction::Hashable do include_context 'concerns', described_class describe '#hash(*args, &block)' do context 'with no arguments' do let(:hash) { instance.hash } it 'returns an Integer' do expect(hash).to be_an Integer end end context 'with arguments' ...
ruby
MIT
97667c8283a4479c7ffc021be31f168d17b20b72
2026-01-04T15:57:54.678054Z
false
AaronLasseigne/active_interaction
https://github.com/AaronLasseigne/active_interaction/blob/97667c8283a4479c7ffc021be31f168d17b20b72/spec/active_interaction/integration/object_interaction_spec.rb
spec/active_interaction/integration/object_interaction_spec.rb
ObjectInteraction = Class.new(TestInteraction) do object :object end RSpec.describe ObjectInteraction do include_context 'interactions' it_behaves_like 'an interaction', :object, -> { // }, class: Regexp it 'succeeds when given nil' do expect { result }.to_not raise_error end end
ruby
MIT
97667c8283a4479c7ffc021be31f168d17b20b72
2026-01-04T15:57:54.678054Z
false
AaronLasseigne/active_interaction
https://github.com/AaronLasseigne/active_interaction/blob/97667c8283a4479c7ffc021be31f168d17b20b72/spec/active_interaction/integration/float_interaction_spec.rb
spec/active_interaction/integration/float_interaction_spec.rb
RSpec.describe 'FloatInteraction' do it_behaves_like 'an interaction', :float, -> { rand } end
ruby
MIT
97667c8283a4479c7ffc021be31f168d17b20b72
2026-01-04T15:57:54.678054Z
false
AaronLasseigne/active_interaction
https://github.com/AaronLasseigne/active_interaction/blob/97667c8283a4479c7ffc021be31f168d17b20b72/spec/active_interaction/integration/record_integration_spec.rb
spec/active_interaction/integration/record_integration_spec.rb
RSpec.describe 'RecordIntegration' do it_behaves_like 'an interaction', :record, -> { Encoding::US_ASCII }, class: Encoding end
ruby
MIT
97667c8283a4479c7ffc021be31f168d17b20b72
2026-01-04T15:57:54.678054Z
false
AaronLasseigne/active_interaction
https://github.com/AaronLasseigne/active_interaction/blob/97667c8283a4479c7ffc021be31f168d17b20b72/spec/active_interaction/integration/interface_interaction_spec.rb
spec/active_interaction/integration/interface_interaction_spec.rb
require 'json' require 'yaml' InterfaceInteraction = Class.new(TestInteraction) do interface :anything, methods: [] end RSpec.describe InterfaceInteraction do include_context 'interactions' it_behaves_like 'an interaction', :interface, -> { [JSON, YAML].sample }, methods: %i[dump load] it 'succee...
ruby
MIT
97667c8283a4479c7ffc021be31f168d17b20b72
2026-01-04T15:57:54.678054Z
false
AaronLasseigne/active_interaction
https://github.com/AaronLasseigne/active_interaction/blob/97667c8283a4479c7ffc021be31f168d17b20b72/spec/active_interaction/integration/integer_interaction_spec.rb
spec/active_interaction/integration/integer_interaction_spec.rb
RSpec.describe 'IntegerInteraction' do it_behaves_like 'an interaction', :integer, -> { rand(1 << 16) } end
ruby
MIT
97667c8283a4479c7ffc021be31f168d17b20b72
2026-01-04T15:57:54.678054Z
false
AaronLasseigne/active_interaction
https://github.com/AaronLasseigne/active_interaction/blob/97667c8283a4479c7ffc021be31f168d17b20b72/spec/active_interaction/integration/date_interaction_spec.rb
spec/active_interaction/integration/date_interaction_spec.rb
RSpec.describe 'DateInteraction' do it_behaves_like 'an interaction', :date, -> { Date.today } end
ruby
MIT
97667c8283a4479c7ffc021be31f168d17b20b72
2026-01-04T15:57:54.678054Z
false
AaronLasseigne/active_interaction
https://github.com/AaronLasseigne/active_interaction/blob/97667c8283a4479c7ffc021be31f168d17b20b72/spec/active_interaction/integration/boolean_interaction_spec.rb
spec/active_interaction/integration/boolean_interaction_spec.rb
BooleanInteraction = Class.new(TestInteraction) do boolean :x end RSpec.describe BooleanInteraction do it_behaves_like 'an interaction', :boolean, -> { [false, true].sample } it 'responds to #x?' do expect(described_class.new).to respond_to(:x?) end end
ruby
MIT
97667c8283a4479c7ffc021be31f168d17b20b72
2026-01-04T15:57:54.678054Z
false
AaronLasseigne/active_interaction
https://github.com/AaronLasseigne/active_interaction/blob/97667c8283a4479c7ffc021be31f168d17b20b72/spec/active_interaction/integration/array_interaction_spec.rb
spec/active_interaction/integration/array_interaction_spec.rb
require 'active_record' require 'sqlite3' ActiveRecord::Base.establish_connection( adapter: 'sqlite3', database: ':memory:' ) ActiveRecord::Schema.define do create_table(:lists) create_table(:elements) { |t| t.column(:list_id, :integer) } end class List < ActiveRecord::Base has_many :elements end class El...
ruby
MIT
97667c8283a4479c7ffc021be31f168d17b20b72
2026-01-04T15:57:54.678054Z
false
AaronLasseigne/active_interaction
https://github.com/AaronLasseigne/active_interaction/blob/97667c8283a4479c7ffc021be31f168d17b20b72/spec/active_interaction/integration/file_interaction_spec.rb
spec/active_interaction/integration/file_interaction_spec.rb
require 'action_dispatch' FileInteraction = Class.new(TestInteraction) do file :a end RSpec.describe FileInteraction do include_context 'interactions' it_behaves_like 'an interaction', :file, -> { File.open(__FILE__) } it 'works with an uploaded file' do file = File.open(__FILE__) uploaded_file = Act...
ruby
MIT
97667c8283a4479c7ffc021be31f168d17b20b72
2026-01-04T15:57:54.678054Z
false
AaronLasseigne/active_interaction
https://github.com/AaronLasseigne/active_interaction/blob/97667c8283a4479c7ffc021be31f168d17b20b72/spec/active_interaction/integration/date_time_interaction_spec.rb
spec/active_interaction/integration/date_time_interaction_spec.rb
RSpec.describe 'DateTimeInteraction' do it_behaves_like 'an interaction', :date_time, -> { DateTime.now } end
ruby
MIT
97667c8283a4479c7ffc021be31f168d17b20b72
2026-01-04T15:57:54.678054Z
false
AaronLasseigne/active_interaction
https://github.com/AaronLasseigne/active_interaction/blob/97667c8283a4479c7ffc021be31f168d17b20b72/spec/active_interaction/integration/time_interaction_spec.rb
spec/active_interaction/integration/time_interaction_spec.rb
TimeWithZone = Class.new do attr_reader :time def initialize(time) @time = time end def ==(other) !other.nil? && time == other.time end def at(*args) TimeWithZone.new(Time.at(*args) + 1) end def parse(*args) TimeWithZone.new(Time.parse(*args) + 1) rescue ArgumentError nil end...
ruby
MIT
97667c8283a4479c7ffc021be31f168d17b20b72
2026-01-04T15:57:54.678054Z
false
AaronLasseigne/active_interaction
https://github.com/AaronLasseigne/active_interaction/blob/97667c8283a4479c7ffc021be31f168d17b20b72/spec/active_interaction/integration/hash_interaction_spec.rb
spec/active_interaction/integration/hash_interaction_spec.rb
HashInteraction = Class.new(TestInteraction) do hash :a do hash :x end hash :b, default: {} do hash :x, default: {} end end RSpec.describe HashInteraction do include_context 'interactions' it_behaves_like 'an interaction', :hash, -> { {} } context 'with inputs[:a]' do let(:a) { { x: {} } } ...
ruby
MIT
97667c8283a4479c7ffc021be31f168d17b20b72
2026-01-04T15:57:54.678054Z
false
AaronLasseigne/active_interaction
https://github.com/AaronLasseigne/active_interaction/blob/97667c8283a4479c7ffc021be31f168d17b20b72/spec/active_interaction/integration/string_interaction_spec.rb
spec/active_interaction/integration/string_interaction_spec.rb
RSpec.describe 'StringInteraction' do it_behaves_like 'an interaction', :string, -> { SecureRandom.hex } end
ruby
MIT
97667c8283a4479c7ffc021be31f168d17b20b72
2026-01-04T15:57:54.678054Z
false
AaronLasseigne/active_interaction
https://github.com/AaronLasseigne/active_interaction/blob/97667c8283a4479c7ffc021be31f168d17b20b72/spec/active_interaction/integration/symbol_interaction_spec.rb
spec/active_interaction/integration/symbol_interaction_spec.rb
RSpec.describe 'SymbolInteraction' do it_behaves_like 'an interaction', :symbol, -> { SecureRandom.hex.to_sym } end
ruby
MIT
97667c8283a4479c7ffc021be31f168d17b20b72
2026-01-04T15:57:54.678054Z
false
AaronLasseigne/active_interaction
https://github.com/AaronLasseigne/active_interaction/blob/97667c8283a4479c7ffc021be31f168d17b20b72/spec/active_interaction/filter/column_spec.rb
spec/active_interaction/filter/column_spec.rb
RSpec.describe ActiveInteraction::Filter::Column do subject(:column) { described_class.intern(type) } let(:type) { :float } describe '.intern(type)' do it 'returns the same object for each type' do expect(described_class.intern(type)).to equal column end it 'returns different objects for diff...
ruby
MIT
97667c8283a4479c7ffc021be31f168d17b20b72
2026-01-04T15:57:54.678054Z
false
AaronLasseigne/active_interaction
https://github.com/AaronLasseigne/active_interaction/blob/97667c8283a4479c7ffc021be31f168d17b20b72/spec/active_interaction/filters/float_filter_spec.rb
spec/active_interaction/filters/float_filter_spec.rb
require 'bigdecimal' RSpec.describe ActiveInteraction::FloatFilter, :filter do include_context 'filters' it_behaves_like 'a filter' describe '#process' do let(:result) { filter.process(value, nil) } context 'with a Float' do let(:value) { rand } it 'returns the Float' do expect(res...
ruby
MIT
97667c8283a4479c7ffc021be31f168d17b20b72
2026-01-04T15:57:54.678054Z
false
AaronLasseigne/active_interaction
https://github.com/AaronLasseigne/active_interaction/blob/97667c8283a4479c7ffc021be31f168d17b20b72/spec/active_interaction/filters/array_filter_spec.rb
spec/active_interaction/filters/array_filter_spec.rb
RSpec.describe ActiveInteraction::ArrayFilter, :filter do include_context 'filters' it_behaves_like 'a filter' context 'with multiple nested filters' do let(:block) do proc do array array end end it 'raises an error' do expect { filter }.to raise_error ActiveInterac...
ruby
MIT
97667c8283a4479c7ffc021be31f168d17b20b72
2026-01-04T15:57:54.678054Z
false
AaronLasseigne/active_interaction
https://github.com/AaronLasseigne/active_interaction/blob/97667c8283a4479c7ffc021be31f168d17b20b72/spec/active_interaction/filters/interface_filter_spec.rb
spec/active_interaction/filters/interface_filter_spec.rb
module InterfaceModule; end class InterfaceClass; end # rubocop:disable Lint/EmptyClass RSpec.describe ActiveInteraction::InterfaceFilter, :filter do include_context 'filters' it_behaves_like 'a filter' do let(:name) { :interface_module } end describe '#process' do let(:result) { filter.process(value...
ruby
MIT
97667c8283a4479c7ffc021be31f168d17b20b72
2026-01-04T15:57:54.678054Z
false
AaronLasseigne/active_interaction
https://github.com/AaronLasseigne/active_interaction/blob/97667c8283a4479c7ffc021be31f168d17b20b72/spec/active_interaction/filters/hash_filter_spec.rb
spec/active_interaction/filters/hash_filter_spec.rb
RSpec.describe ActiveInteraction::HashFilter, :filter do include_context 'filters' it_behaves_like 'a filter' context 'with a nested nameless filter' do let(:block) { proc { hash } } it 'raises an error' do expect { filter }.to raise_error ActiveInteraction::InvalidFilterError end end des...
ruby
MIT
97667c8283a4479c7ffc021be31f168d17b20b72
2026-01-04T15:57:54.678054Z
false
AaronLasseigne/active_interaction
https://github.com/AaronLasseigne/active_interaction/blob/97667c8283a4479c7ffc021be31f168d17b20b72/spec/active_interaction/filters/object_filter_spec.rb
spec/active_interaction/filters/object_filter_spec.rb
class ObjectThing def self.converter(_) @converter ||= new end def self.converter_with_error(_) raise 'error' end end class ObjectThings; end # rubocop:disable Lint/EmptyClass BackupObjectThing = ObjectThing RSpec.describe ActiveInteraction::ObjectFilter, :filter do include_context 'filters' befo...
ruby
MIT
97667c8283a4479c7ffc021be31f168d17b20b72
2026-01-04T15:57:54.678054Z
false
AaronLasseigne/active_interaction
https://github.com/AaronLasseigne/active_interaction/blob/97667c8283a4479c7ffc021be31f168d17b20b72/spec/active_interaction/filters/abstract_numeric_filter_spec.rb
spec/active_interaction/filters/abstract_numeric_filter_spec.rb
RSpec.describe ActiveInteraction::AbstractNumericFilter, :filter do include_context 'filters' describe '#process' do let(:value) { nil } it 'raises an error' do expect { filter.process(value, nil) }.to raise_error NameError end end end
ruby
MIT
97667c8283a4479c7ffc021be31f168d17b20b72
2026-01-04T15:57:54.678054Z
false
AaronLasseigne/active_interaction
https://github.com/AaronLasseigne/active_interaction/blob/97667c8283a4479c7ffc021be31f168d17b20b72/spec/active_interaction/filters/integer_filter_spec.rb
spec/active_interaction/filters/integer_filter_spec.rb
RSpec.describe ActiveInteraction::IntegerFilter, :filter do include_context 'filters' it_behaves_like 'a filter' describe '#process' do let(:result) { filter.process(value, nil) } context 'with an Integer' do let(:value) { rand(1 << 16) } it 'returns the Integer' do expect(result.va...
ruby
MIT
97667c8283a4479c7ffc021be31f168d17b20b72
2026-01-04T15:57:54.678054Z
false
AaronLasseigne/active_interaction
https://github.com/AaronLasseigne/active_interaction/blob/97667c8283a4479c7ffc021be31f168d17b20b72/spec/active_interaction/filters/record_filter_spec.rb
spec/active_interaction/filters/record_filter_spec.rb
class RecordThing def self.find(_) raise 'error' end def self.finder(_) @finder ||= new end def self.finds_nil(_) nil end def self.finds_bad_value(_) Object.new end end class RecordThings; end # rubocop:disable Lint/EmptyClass BackupRecordThing = RecordThing RSpec.describe ActiveInt...
ruby
MIT
97667c8283a4479c7ffc021be31f168d17b20b72
2026-01-04T15:57:54.678054Z
false
AaronLasseigne/active_interaction
https://github.com/AaronLasseigne/active_interaction/blob/97667c8283a4479c7ffc021be31f168d17b20b72/spec/active_interaction/filters/time_filter_spec.rb
spec/active_interaction/filters/time_filter_spec.rb
RSpec.describe ActiveInteraction::TimeFilter, :filter do include_context 'filters' it_behaves_like 'a filter' shared_context 'with format' do let(:format) { '%d/%m/%Y %H:%M:%S %z' } before do options[:format] = format end end describe '#initialize' do context 'with a format' do ...
ruby
MIT
97667c8283a4479c7ffc021be31f168d17b20b72
2026-01-04T15:57:54.678054Z
false
AaronLasseigne/active_interaction
https://github.com/AaronLasseigne/active_interaction/blob/97667c8283a4479c7ffc021be31f168d17b20b72/spec/active_interaction/filters/date_time_filter_spec.rb
spec/active_interaction/filters/date_time_filter_spec.rb
RSpec.describe ActiveInteraction::DateTimeFilter, :filter do include_context 'filters' it_behaves_like 'a filter' shared_context 'with format' do let(:format) { '%d/%m/%Y %H:%M:%S %:z' } before do options[:format] = format end end describe '#process' do let(:result) { filter.process(v...
ruby
MIT
97667c8283a4479c7ffc021be31f168d17b20b72
2026-01-04T15:57:54.678054Z
false
AaronLasseigne/active_interaction
https://github.com/AaronLasseigne/active_interaction/blob/97667c8283a4479c7ffc021be31f168d17b20b72/spec/active_interaction/filters/date_filter_spec.rb
spec/active_interaction/filters/date_filter_spec.rb
RSpec.describe ActiveInteraction::DateFilter, :filter do include_context 'filters' it_behaves_like 'a filter' shared_context 'with format' do let(:format) { '%d/%m/%Y' } before do options[:format] = format end end describe '#process' do let(:result) { filter.process(value, nil) } ...
ruby
MIT
97667c8283a4479c7ffc021be31f168d17b20b72
2026-01-04T15:57:54.678054Z
false
AaronLasseigne/active_interaction
https://github.com/AaronLasseigne/active_interaction/blob/97667c8283a4479c7ffc021be31f168d17b20b72/spec/active_interaction/filters/file_filter_spec.rb
spec/active_interaction/filters/file_filter_spec.rb
RSpec.describe ActiveInteraction::FileFilter, :filter do include_context 'filters' it_behaves_like 'a filter' describe '#process' do let(:result) { filter.process(value, nil) } context 'with a File' do let(:value) { File.new(__FILE__) } it 'returns the File' do expect(result.value)....
ruby
MIT
97667c8283a4479c7ffc021be31f168d17b20b72
2026-01-04T15:57:54.678054Z
false
AaronLasseigne/active_interaction
https://github.com/AaronLasseigne/active_interaction/blob/97667c8283a4479c7ffc021be31f168d17b20b72/spec/active_interaction/filters/symbol_filter_spec.rb
spec/active_interaction/filters/symbol_filter_spec.rb
RSpec.describe ActiveInteraction::SymbolFilter, :filter do include_context 'filters' it_behaves_like 'a filter' describe '#process' do let(:result) { filter.process(value, nil) } context 'with a Symbol' do let(:value) { SecureRandom.hex.to_sym } it 'returns the Symbol' do expect(res...
ruby
MIT
97667c8283a4479c7ffc021be31f168d17b20b72
2026-01-04T15:57:54.678054Z
false
AaronLasseigne/active_interaction
https://github.com/AaronLasseigne/active_interaction/blob/97667c8283a4479c7ffc021be31f168d17b20b72/spec/active_interaction/filters/boolean_filter_spec.rb
spec/active_interaction/filters/boolean_filter_spec.rb
RSpec.describe ActiveInteraction::BooleanFilter, :filter do include_context 'filters' it_behaves_like 'a filter' describe '#process' do context 'falsey' do [false, '0', 'false', 'FALSE', 'off', 'OFF'].each do |value| it "returns false for #{value.inspect}" do expect(filter.process(val...
ruby
MIT
97667c8283a4479c7ffc021be31f168d17b20b72
2026-01-04T15:57:54.678054Z
false
AaronLasseigne/active_interaction
https://github.com/AaronLasseigne/active_interaction/blob/97667c8283a4479c7ffc021be31f168d17b20b72/spec/active_interaction/filters/abstract_date_time_filter_spec.rb
spec/active_interaction/filters/abstract_date_time_filter_spec.rb
RSpec.describe ActiveInteraction::AbstractDateTimeFilter, :filter do include_context 'filters' describe '#process' do let(:value) { nil } it 'raises an error' do expect { filter.process(value, nil) }.to raise_error NameError end end end
ruby
MIT
97667c8283a4479c7ffc021be31f168d17b20b72
2026-01-04T15:57:54.678054Z
false
AaronLasseigne/active_interaction
https://github.com/AaronLasseigne/active_interaction/blob/97667c8283a4479c7ffc021be31f168d17b20b72/spec/active_interaction/filters/string_filter_spec.rb
spec/active_interaction/filters/string_filter_spec.rb
RSpec.describe ActiveInteraction::StringFilter, :filter do include_context 'filters' it_behaves_like 'a filter' shared_context 'without strip' do before do options[:strip] = false end end describe '#process' do let(:result) { filter.process(value, nil) } context 'with a String' do ...
ruby
MIT
97667c8283a4479c7ffc021be31f168d17b20b72
2026-01-04T15:57:54.678054Z
false
AaronLasseigne/active_interaction
https://github.com/AaronLasseigne/active_interaction/blob/97667c8283a4479c7ffc021be31f168d17b20b72/spec/active_interaction/filters/decimal_filter_spec.rb
spec/active_interaction/filters/decimal_filter_spec.rb
RSpec.describe ActiveInteraction::DecimalFilter, :filter do include_context 'filters' it_behaves_like 'a filter' shared_context 'with digits' do let(:digits) { 4 } before do options[:digits] = digits end end describe '#process' do let(:result) { filter.process(value, nil) } conte...
ruby
MIT
97667c8283a4479c7ffc021be31f168d17b20b72
2026-01-04T15:57:54.678054Z
false
AaronLasseigne/active_interaction
https://github.com/AaronLasseigne/active_interaction/blob/97667c8283a4479c7ffc021be31f168d17b20b72/lib/active_interaction.rb
lib/active_interaction.rb
# frozen_string_literal: true require 'active_model' require 'active_support/core_ext/hash/indifferent_access' # Manage application specific business logic. # # @author Aaron Lasseigne <aaron.lasseigne@gmail.com> # @author Taylor Fausak <taylor@fausak.me> module ActiveInteraction end require_relative 'active_interac...
ruby
MIT
97667c8283a4479c7ffc021be31f168d17b20b72
2026-01-04T15:57:54.678054Z
false
AaronLasseigne/active_interaction
https://github.com/AaronLasseigne/active_interaction/blob/97667c8283a4479c7ffc021be31f168d17b20b72/lib/active_interaction/version.rb
lib/active_interaction/version.rb
# frozen_string_literal: true module ActiveInteraction # The version number. # # @return [Gem::Version] VERSION = Gem::Version.new('5.5.0') end
ruby
MIT
97667c8283a4479c7ffc021be31f168d17b20b72
2026-01-04T15:57:54.678054Z
false
AaronLasseigne/active_interaction
https://github.com/AaronLasseigne/active_interaction/blob/97667c8283a4479c7ffc021be31f168d17b20b72/lib/active_interaction/exceptions.rb
lib/active_interaction/exceptions.rb
# frozen_string_literal: true module ActiveInteraction # Top-level error class. All other errors subclass this. Error = Class.new(StandardError) # Raised if a constant name is invalid. InvalidNameError = Class.new(Error) # Raised if a converter is invalid. InvalidConverterError = Class.new(Error) # Ra...
ruby
MIT
97667c8283a4479c7ffc021be31f168d17b20b72
2026-01-04T15:57:54.678054Z
false
AaronLasseigne/active_interaction
https://github.com/AaronLasseigne/active_interaction/blob/97667c8283a4479c7ffc021be31f168d17b20b72/lib/active_interaction/errors.rb
lib/active_interaction/errors.rb
# frozen_string_literal: true module ActiveInteraction # An extension that provides the ability to merge other errors into itself. class Errors < ActiveModel::Errors attr_accessor :backtrace # Merge other errors into this one. # # @param other [Errors] # # @return [Errors] def merge!(o...
ruby
MIT
97667c8283a4479c7ffc021be31f168d17b20b72
2026-01-04T15:57:54.678054Z
false
AaronLasseigne/active_interaction
https://github.com/AaronLasseigne/active_interaction/blob/97667c8283a4479c7ffc021be31f168d17b20b72/lib/active_interaction/filter.rb
lib/active_interaction/filter.rb
# frozen_string_literal: true require 'active_support/inflector' module ActiveInteraction # @!macro [new] filter_method_params # @param *attributes [Array<Symbol>] Attributes to create. # @param options [Hash{Symbol => Object}] # # @option options [Object] :default Fallback value if `nil` is given. ...
ruby
MIT
97667c8283a4479c7ffc021be31f168d17b20b72
2026-01-04T15:57:54.678054Z
false
AaronLasseigne/active_interaction
https://github.com/AaronLasseigne/active_interaction/blob/97667c8283a4479c7ffc021be31f168d17b20b72/lib/active_interaction/base.rb
lib/active_interaction/base.rb
# frozen_string_literal: true module ActiveInteraction # @abstract Subclass and override {#execute} to implement a custom # ActiveInteraction::Base class. # # Provides interaction functionality. Subclass this to create an interaction. # # @example # class ExampleInteraction < ActiveInteraction::Base ...
ruby
MIT
97667c8283a4479c7ffc021be31f168d17b20b72
2026-01-04T15:57:54.678054Z
false
AaronLasseigne/active_interaction
https://github.com/AaronLasseigne/active_interaction/blob/97667c8283a4479c7ffc021be31f168d17b20b72/lib/active_interaction/input.rb
lib/active_interaction/input.rb
# frozen_string_literal: true module ActiveInteraction # Represents a processed input. class Input # @private def initialize(filter, value: nil, error: nil) @filter = filter @value = value @error = error end # The processed input value. attr_reader :value # Any errors th...
ruby
MIT
97667c8283a4479c7ffc021be31f168d17b20b72
2026-01-04T15:57:54.678054Z
false
AaronLasseigne/active_interaction
https://github.com/AaronLasseigne/active_interaction/blob/97667c8283a4479c7ffc021be31f168d17b20b72/lib/active_interaction/array_input.rb
lib/active_interaction/array_input.rb
# frozen_string_literal: true module ActiveInteraction # Represents a processed array input. class ArrayInput < Input # @private def initialize(filter, value: nil, error: nil, index_errors: false, children: []) super(filter, value: value, error: error) @filter = filter @index_errors = in...
ruby
MIT
97667c8283a4479c7ffc021be31f168d17b20b72
2026-01-04T15:57:54.678054Z
false