Sha256: 770fd1180a620565c38f4f575147d34996e1eba2321f1dbd33faf25a05419895

Contents?: true

Size: 733 Bytes

Versions: 2

Compression:

Stored size: 733 Bytes

Contents

module Locomotive
  class ContentTypeService < Struct.new(:site)

    def list
      site
      .content_types
      .order_by(:'display_settings.position'.asc, :name.asc)
      .pluck(:_id, :name, :slug, :number_of_entries, :display_settings)
      .map do |(_id, name, slug, number_of_entries, display_settings)|
        Locomotive::ContentType.new(
          _id: _id,
          name: name,
          slug: slug,
          number_of_entries: number_of_entries,
          display_settings: display_settings
        )
      end
    end

    def find_by_slug(slug)
      site.content_types.by_id_or_slug(slug)
    end

    def update(content_type, attributes = {})
      content_type.update_attributes(attributes)
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
locomotivecms-4.2.0.alpha2 app/services/locomotive/content_type_service.rb
locomotivecms-4.2.0.alpha1 app/services/locomotive/content_type_service.rb