Sha256: d00685f15c5a0128afa3876345b58626f454a9b1eb0e52dc270f8a67581398db

Contents?: true

Size: 829 Bytes

Versions: 3

Compression:

Stored size: 829 Bytes

Contents

module Comable
  class Theme < ActiveRecord::Base
    has_one :store, class_name: Comable::Store.name

    validates :name, uniqueness: { scope: :version }
    validates :name, presence: true, length: { maximum: 255 }
    validates :version, presence: true, length: { maximum: 255 }
    validates :display, length: { maximum: 255 }
    validates :description, length: { maximum: 255 }
    validates :homepage, length: { maximum: 255 }
    validates :author, length: { maximum: 255 }

    scope :by_newest, -> { reorder(created_at: :desc) }

    class << self
      def dir
        Rails.root.join('themes')
      end
    end

    def dir
      self.class.dir + name
    end

    def default_version
      '0.1.0'
    end

    def to_param
      name
    end

    def display_name
      display.presence || name
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
comable-core-0.7.1 app/models/comable/theme.rb
comable-core-0.7.0 app/models/comable/theme.rb
comable-core-0.7.0.beta2 app/models/comable/theme.rb