Module: ROM::Plugins::Relation::SQL::AutoRestrictions

Extended by:
Notifications::Listener
Defined in:
lib/rom/plugins/relation/sql/auto_restrictions.rb

Overview

Generates methods for restricting relations by their indexed attributes

Examples:

rom = ROM.container(:sql, 'sqlite::memory') do |config|
  config.create_table(:users) do
    primary_key :id
    column :email, String, null: false, unique: true
  end

  config.plugin(:sql, relations: :auto_restrictions)

  config.relation(:users) do
    schema(infer: true)
  end
end

# now `by_email` is available automatically
rom.relations[:users].by_email('jane@doe.org')