Sha256: 550e803a183f7af670417cd1220deb97c4ff99dd5aa8eacaa30229ceec736456

Contents?: true

Size: 894 Bytes

Versions: 13

Compression:

Stored size: 894 Bytes

Contents

module Locomotive
  module Extensions
    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

13 entries across 13 versions & 1 rubygems

Version Path
locomotive_cms-2.5.7 app/models/locomotive/extensions/asset/types.rb
locomotive_cms-2.5.6 app/models/locomotive/extensions/asset/types.rb
locomotive_cms-2.5.6.rc2 app/models/locomotive/extensions/asset/types.rb
locomotive_cms-2.5.6.rc1 app/models/locomotive/extensions/asset/types.rb
locomotive_cms-2.5.5 app/models/locomotive/extensions/asset/types.rb
locomotive_cms-2.5.4 app/models/locomotive/extensions/asset/types.rb
locomotive_cms-2.5.3 app/models/locomotive/extensions/asset/types.rb
locomotive_cms-2.5.2 app/models/locomotive/extensions/asset/types.rb
locomotive_cms-2.5.1 app/models/locomotive/extensions/asset/types.rb
locomotive_cms-2.5.0 app/models/locomotive/extensions/asset/types.rb
locomotive_cms-2.5.0.rc3 app/models/locomotive/extensions/asset/types.rb
locomotive_cms-2.5.0.rc2 app/models/locomotive/extensions/asset/types.rb
locomotive_cms-2.5.0.rc1 app/models/locomotive/extensions/asset/types.rb