Module: Cms::Behaviors::Publishing::MacroMethods

Defined in:
lib/cms/behaviors/publishing.rb

Instance Method Summary collapse

Instance Method Details

#is_publishable(options = {}) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/cms/behaviors/publishing.rb', line 19

def is_publishable(options={})
  @is_publishable = true
  extend ClassMethods
  include InstanceMethods

  attr_accessor :publish_on_save
  attr_accessible :publish_on_save

  after_save :publish_for_non_versioned

  scope :published, :conditions => {:published => true}
  scope :unpublished, lambda {
    if versioned?
      { :joins => :versions,
        :conditions =>
          "#{connection.quote_table_name(version_table_name)}.#{connection.quote_column_name('version')} > " +
          "#{connection.quote_table_name(table_name)}.#{connection.quote_column_name('version')}",
        :select => "distinct #{connection.quote_table_name(table_name)}.*" }
    else
      { :conditions => { :published => false } }
    end
  }

end

#publishable?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/cms/behaviors/publishing.rb', line 16

def publishable?
  !!@is_publishable
end