Sha256: 9092b298e30c455d97191eb11be108c69e4955a22e6a1e3caad251a3c422e400

Contents?: true

Size: 536 Bytes

Versions: 11

Compression:

Stored size: 536 Bytes

Contents

module Spina
  module Partable
    extend ActiveSupport::Concern

    included do
      def part(attributes)
        part = parts.where(name: attributes[:name]).first_or_initialize(attributes)
        part.partable = part.partable_type.constantize.new if part.partable.blank?
        part.options = attributes[:options]
        part
      end

      def has_content?(name)
        content(name).present?
      end

      def content(name)
        part = parts.find_by(name: name)
        part.try(:content)
      end

    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
spina-1.2.0 app/models/concerns/spina/partable.rb
spina-1.1.4 app/models/concerns/spina/partable.rb
spina-1.1.3 app/models/concerns/spina/partable.rb
spina-1.1.2 app/models/concerns/spina/partable.rb
spina-1.1.1 app/models/concerns/spina/partable.rb
spina-1.1.0 app/models/concerns/spina/partable.rb
spina-1.0.3 app/models/concerns/spina/partable.rb
spina-1.0.2 app/models/concerns/spina/partable.rb
spina-1.0.1 app/models/concerns/spina/partable.rb
spina-1.0.0 app/models/concerns/spina/partable.rb
spina-0.12.0 app/models/concerns/spina/partable.rb