Sha256: 59965f5e4a0d3ed7d374fc20570b15d4991683a8c3f3c63924db3f9c028248df

Contents?: true

Size: 637 Bytes

Versions: 13

Compression:

Stored size: 637 Bytes

Contents

module Locomotive
  module Extensions
    module Asset
      module Types

        extend ActiveSupport::Concern

        included do
          %w{media image stylesheet javascript font pdf}.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 by_content_type(content_type)
            return self.all if content_type.blank?

            self.all.where(content_type: content_type.to_s)
          end

        end

      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
locomotive_cms-2.4.1 app/models/locomotive/extensions/asset/types.rb
locomotive_cms-2.4.0 app/models/locomotive/extensions/asset/types.rb
locomotive_cms-2.3.1 app/models/locomotive/extensions/asset/types.rb
locomotive_cms-2.3.0 app/models/locomotive/extensions/asset/types.rb
locomotive_cms-2.2.3 app/models/locomotive/extensions/asset/types.rb
locomotive_cms-2.2.2 app/models/locomotive/extensions/asset/types.rb
locomotive_cms-2.2.1 app/models/locomotive/extensions/asset/types.rb
locomotive_cms-2.2.0 app/models/locomotive/extensions/asset/types.rb
locomotive_cms-2.1.4 app/models/locomotive/extensions/asset/types.rb
locomotive_cms-2.1.3 app/models/locomotive/extensions/asset/types.rb
locomotive_cms-2.1.2 app/models/locomotive/extensions/asset/types.rb
locomotive_cms-2.1.1 app/models/locomotive/extensions/asset/types.rb
locomotive_cms-2.1.0 app/models/locomotive/extensions/asset/types.rb