Sha256: fb5a1edfb67649b06c780f433f75b1c0e7b0e0f6290ab31bb60f4313982e9d78

Contents?: true

Size: 781 Bytes

Versions: 5

Compression:

Stored size: 781 Bytes

Contents

# encoding: UTF-8

module Spontaneous::Model
  module Piece
    extend Spontaneous::Concern

    include Spontaneous::Model::Core::Supertype

    # Public: for Pieces #parent is the same as the #owner
    # whereas for pages, parent is the next page up in the
    # page hierarchy.
    #
    # Returns: Content node one up in the page hierarchy
    def parent
      owner
    end

    def export(user = nil)
      super(user).merge(export_styles)
    end


    def export_styles
      h = { :style => style_sid.to_s }
      if container
        h.merge!({
          :styles => container.available_styles(self).map { |s| s.schema_id.to_s }
        })
      else
        h.merge!({
          :styles => self.styles.map { |s| s.schema_id.to_s }
        })
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
spontaneous-0.2.0.beta5 lib/spontaneous/model/piece.rb
spontaneous-0.2.0.beta4 lib/spontaneous/model/piece.rb
spontaneous-0.2.0.beta3 lib/spontaneous/model/piece.rb
spontaneous-0.2.0.beta2 lib/spontaneous/model/piece.rb
spontaneous-0.2.0.beta1 lib/spontaneous/model/piece.rb