Sha256: 08f753d9ef23fb06522c4737df37aff817600869314b007559ca326e38906df7

Contents?: true

Size: 598 Bytes

Versions: 2

Compression:

Stored size: 598 Bytes

Contents

require 'active_support/concern'

module SimplePages
  module Models
    module PageCluster
      extend ActiveSupport::Concern
      included do
        serialize :cluster
      end

      module ClassMethods
        def without_cluster
          where(cluster: [nil, "--- \n...\n"])
        end

        def with_cluster(name)
          where('cluster LIKE ?', "%#{name}%")
        end
      end

      def cluster=(values)
        values = values.delete_if { |v| v.blank? }
        if values.blank?
          super nil
        else
          super values
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
simple-pages-rails-0.7.0 lib/simple_pages/models/page_cluster.rb
simple-pages-rails-0.6.0 lib/simple_pages/models/page_cluster.rb