Sha256: 5708ca3d43ef8ef221e6ac0a314c29ef04ee9728b4884cfccfaed6aac0221375

Contents?: true

Size: 890 Bytes

Versions: 8

Compression:

Stored size: 890 Bytes

Contents

require "active_record"
require "shamu/entities/active_record"
require "shamu/entities/active_record_soft_destroy"

module ActiveRecordSpec
  class Favorite < ::ActiveRecord::Base
    self.table_name = "favorites"
    extend ::Shamu::Entities::ActiveRecord
    include ::Shamu::Entities::ActiveRecordSoftDestroy

    scope :by_name, ->( name ) { where( name: name ) }
    scope :by_label, ->( label ) { where( label: label ) }
  end

  class FavoriteMigration < ::ActiveRecord::Migration
    def self.up
      create_table :favorites do |t|
        t.string :name
        t.string :label

        t.datetime :destroyed_at
      end
    end

    def self.down
      drop_table :favorites
    end
  end

  class FavoriteScope < Shamu::Entities::ListScope
    attribute :name
  end

  class FavoriteEntity < Shamu::Entities::Entity
    model :record
    attribute :name, on: :record
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
shamu-0.0.24 spec/lib/shamu/active_record_support.rb
shamu-0.0.21 spec/lib/shamu/active_record_support.rb
shamu-0.0.20 spec/lib/shamu/active_record_support.rb
shamu-0.0.19 spec/lib/shamu/active_record_support.rb
shamu-0.0.18 spec/lib/shamu/active_record_support.rb
shamu-0.0.17 spec/lib/shamu/active_record_support.rb
shamu-0.0.15 spec/lib/shamu/active_record_support.rb
shamu-0.0.14 spec/lib/shamu/active_record_support.rb