Sha256: 773da67e59713de2d7c272ae8444d694e8eb4156f826528d7cab7014271509ce
Contents?: true
Size: 795 Bytes
Versions: 2
Compression:
Stored size: 795 Bytes
Contents
module Workarea module Catalog class Swatch include ApplicationDocument extend Dragonfly::Model field :_id, type: String, default: -> { name.optionize } field :name, type: String field :hex, type: String field :image_name, type: String field :image_uid, type: String validates :name, presence: true validates :hex, length: { is: 7, allow_blank: true } validates :id, uniqueness: true dragonfly_accessor :image, app: :workarea before_validation :normalize_hex def image? image.present? end def hex? hex.present? end private def normalize_hex return if hex.blank? self.hex = hex.starts_with?('#') ? hex : "##{hex}" end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
workarea-swatches-1.0.6 | app/models/workarea/catalog/swatch.rb |
workarea-swatches-1.0.5 | app/models/workarea/catalog/swatch.rb |