Sha256: b01abd814c8cd9c590d1b6b24d04ed7036bb493c8ddd3c055f479911aad15c60

Contents?: true

Size: 821 Bytes

Versions: 32

Compression:

Stored size: 821 Bytes

Contents

class Pulitzer::PostTypeVersion::Preview
  include StateMachine::Transition

  self.action_name = :preview
  self.target_state = 'preview'
  self.valid_from_states = [:incomplete]

  def initialize(post_type_version)
    @post_type_version = post_type_version
    self.object = @post_type_version
    self.errors = ActiveModel::Errors.new(self)
  end

  def preview
    self.validate_transition!
    validate_elements or return false
    update_status
    return true
  end

  def validate_elements
    if @post_type_version.post_type_content_element_types.empty? &&
        @post_type_version.free_form_section_types.empty?
      @post_type_version.errors.add(:base, 'You must set up all the content elements and free form sections before previewing the post type')
      return false
    end
    return true
  end

end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
pulitzer-0.15.31 app/services/pulitzer/post_type_version/preview.rb
pulitzer-0.15.30 app/services/pulitzer/post_type_version/preview.rb
pulitzer-0.15.29 app/services/pulitzer/post_type_version/preview.rb
pulitzer-0.15.28 app/services/pulitzer/post_type_version/preview.rb
pulitzer-0.15.27 app/services/pulitzer/post_type_version/preview.rb
pulitzer-0.15.26 app/services/pulitzer/post_type_version/preview.rb
pulitzer-0.15.25 app/services/pulitzer/post_type_version/preview.rb
pulitzer-0.15.24 app/services/pulitzer/post_type_version/preview.rb
pulitzer-0.15.23 app/services/pulitzer/post_type_version/preview.rb
pulitzer-0.15.22 app/services/pulitzer/post_type_version/preview.rb
pulitzer-0.15.21 app/services/pulitzer/post_type_version/preview.rb
pulitzer-0.15.20 app/services/pulitzer/post_type_version/preview.rb
pulitzer-0.15.19 app/services/pulitzer/post_type_version/preview.rb
pulitzer-0.15.18 app/services/pulitzer/post_type_version/preview.rb
pulitzer-0.15.17 app/services/pulitzer/post_type_version/preview.rb
pulitzer-0.15.16 app/services/pulitzer/post_type_version/preview.rb
pulitzer-0.15.15 app/services/pulitzer/post_type_version/preview.rb
pulitzer-0.15.14 app/services/pulitzer/post_type_version/preview.rb
pulitzer-0.15.13 app/services/pulitzer/post_type_version/preview.rb
pulitzer-0.15.12 app/services/pulitzer/post_type_version/preview.rb