Sha256: fbbd14bca71ceb48cefec43605c67b78a49bb12e047dec2b3d6d253acf956ae4

Contents?: true

Size: 900 Bytes

Versions: 42

Compression:

Stored size: 900 Bytes

Contents

module Locomotive
  module Concerns
    module Asset
      module Types

        extend ActiveSupport::Concern

        included do
          scope :by_content_type,   ->(content_type)  { content_type.blank? ? all : where(content_type: content_type.to_s) }
          scope :by_content_types,  ->(content_types) { content_types.blank? ? all : where(:content_type.in => [*content_types]) }

          all_types.each do |type|
            scope :"only_#{type}", -> { where(content_type: type) }

            define_method("#{type}?") do
              self.content_type.to_s == type
            end
          end
        end

        module ClassMethods

          def all_types
            %w{image pdf media stylesheet javascript font}
          end

          def types_for_content_editing
            all_types - %w(stylesheet javascript font)
          end

        end

      end
    end
  end
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
locomotivecms-4.2.0.alpha2 app/models/locomotive/concerns/asset/types.rb
locomotivecms-4.2.0.alpha1 app/models/locomotive/concerns/asset/types.rb
locomotivecms-4.1.1 app/models/locomotive/concerns/asset/types.rb
locomotivecms-4.1.0 app/models/locomotive/concerns/asset/types.rb
locomotivecms-4.1.0.rc1 app/models/locomotive/concerns/asset/types.rb
locomotivecms-4.0.3 app/models/locomotive/concerns/asset/types.rb
locomotivecms-4.0.2 app/models/locomotive/concerns/asset/types.rb
locomotivecms-4.0.1 app/models/locomotive/concerns/asset/types.rb
locomotivecms-4.0.0 app/models/locomotive/concerns/asset/types.rb
locomotivecms-4.0.0.rc0 app/models/locomotive/concerns/asset/types.rb
locomotivecms-4.0.0.alpha3 app/models/locomotive/concerns/asset/types.rb
locomotivecms-3.4.1 app/models/locomotive/concerns/asset/types.rb
locomotivecms-4.0.0.alpha2 app/models/locomotive/concerns/asset/types.rb
locomotivecms-4.0.0.alpha1 app/models/locomotive/concerns/asset/types.rb
locomotivecms-3.4.0 app/models/locomotive/concerns/asset/types.rb
locomotivecms-3.3.0 app/models/locomotive/concerns/asset/types.rb
locomotivecms-3.3.0.rc3 app/models/locomotive/concerns/asset/types.rb
locomotivecms-3.3.0.rc2 app/models/locomotive/concerns/asset/types.rb
locomotivecms-3.1.2 app/models/locomotive/concerns/asset/types.rb
locomotivecms-3.2.1 app/models/locomotive/concerns/asset/types.rb