Sha256: cb1547835576ed2ca8791f4276b9f459c1c02089216d7541e609ce590646d59c

Contents?: true

Size: 449 Bytes

Versions: 2

Compression:

Stored size: 449 Bytes

Contents

# Additions to ActiveRecord::Base.
module Pose
  module ActiveRecordBaseAdditions

    # Defines the searchable content in ActiveRecord objects.
    def posify *source_methods, &block
      include ModelClassAdditions

      self.pose_content = proc do
        text_chunks = source_methods.map { |source| send(source) }
        text_chunks << instance_eval(&block) if block
        text_chunks.reject(&:blank?).join(' ')
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pose-3.2.0 lib/pose/activerecord_base_additions.rb
pose-3.1.1 lib/pose/activerecord_base_additions.rb