Sha256: 312095b709571b8a7952d9fc0dab4e4aea246ddad2d7d8b4d5004e454bfea4ed

Contents?: true

Size: 943 Bytes

Versions: 5

Compression:

Stored size: 943 Bytes

Contents

module Spontaneous::Rack
  module Back
    class Base < ServerBase
      helpers  Helpers

      set :views, Proc.new { Spontaneous.application_dir + '/views' }

      def content_model
        site.model
      end

      def update_fields(content, field_data)
        return unless field_data
        Spontaneous::Field.update_asynchronously(site, content, field_data, user)
        json(content)
      end

      def content_for_request(lock = false)
        content_model.db.transaction do
          dataset = lock ? content_model.for_update : content_model
          content = dataset.get(params[:id])
          halt 404 if content.nil?
          content.current_editor = user
          if box_id = content_model.schema.uids[params[:box_id]]
            box = content.boxes.detect { |b| b.schema_id == box_id }
            yield(content, box)
          else
            yield(content)
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
spontaneous-0.2.0.beta9 lib/spontaneous/rack/back/base.rb
spontaneous-0.2.0.beta8 lib/spontaneous/rack/back/base.rb
spontaneous-0.2.0.beta7 lib/spontaneous/rack/back/base.rb
spontaneous-0.2.0.beta6 lib/spontaneous/rack/back/base.rb
spontaneous-0.2.0.beta5 lib/spontaneous/rack/back/base.rb