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

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

Instance Method Summary collapse

Instance Method Details

#is_publishable(options = {}) ⇒ Object



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

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

  #attr_accessible :publish_on_save, :as
  after_save :publish_for_non_versioned

  scope :published, -> { where(:published => true) }
  scope :unpublished, -> {
    if self.versioned?
      q = "#{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)}.*").where(q).joins(:versions)
    else
      where(:published => false)
    end
  }

end

#publishable?Boolean

Returns:

  • (Boolean)


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

def publishable?
  !!@is_publishable
end