Module: Skyline::Content::Content::KlassMethods

Defined in:
lib/skyline/content/content.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#content?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/skyline/content/content.rb', line 36

def content?
  true
end

#count_for_cms(*args) ⇒ Object

Same as find_for_cms but this method only returns a count. –



103
104
105
106
107
108
# File 'lib/skyline/content/content.rb', line 103

def count_for_cms(*args)
  skyline_options,options = extract_all_options!(args)        
  with_skyline_scope(skyline_options) do
   count(*(args << options))
  end         
end

#exportable?Boolean

Is this object exportable

Returns:

  • (Boolean)


67
68
69
# File 'lib/skyline/content/content.rb', line 67

def exportable?
  false
end

#filterable?Boolean

Is this object filterable? Basically means wether or not this object has fields with the metadata :filter set to true.

Returns:

  • (Boolean)


57
58
59
# File 'lib/skyline/content/content.rb', line 57

def filterable?
  self.filterable_fields.any?
end

#find_for_cms(*args) ⇒ Object

Find objects for use in the CMS, these are wrappers for the standard find method of ActiveRecord::Base with some extra options.

Parameters

See ActiveRecord::Base.find for more info on the standard parameters

Options

:self_referential<Boolean>

If false, will only find records where the associations to other objects of the same class are null. Which basically means it get’s the top level of the hierarchy.

:filter<Hash>



92
93
94
95
96
97
98
99
# File 'lib/skyline/content/content.rb', line 92

def find_for_cms(*args)
  skyline_options,options = extract_all_options!(args)
    
  with_skyline_scope(skyline_options) do
   options.update(:order => self.default_order_by_statement)
   find(*(args << options))
  end
end

#importable?Boolean

Is this object importable

Returns:

  • (Boolean)


72
73
74
# File 'lib/skyline/content/content.rb', line 72

def importable?
  false
end

#orderable?Boolean

Does this object have a position field

Returns:

  • (Boolean)


62
63
64
# File 'lib/skyline/content/content.rb', line 62

def orderable?
  false
end

#paginate_for_cms(*args) ⇒ Object

Same as find_for_cms, but works with the will_paginate plugin –



112
113
114
115
116
117
118
# File 'lib/skyline/content/content.rb', line 112

def paginate_for_cms(*args)
  skyline_options, options = extract_all_options!(args)        
  with_skyline_scope(skyline_options) do
   options.update(:order => self.default_order_by_statement)
   paginate(*(args << options))
  end         
end

#publishable?Boolean

Does this object have a published field

Returns:

  • (Boolean)


41
42
43
44
45
# File 'lib/skyline/content/content.rb', line 41

def publishable?
  self.column_names.include?("published")
rescue
  true
end

#taggable?Boolean

Does this object have tags

Returns:

  • (Boolean)


48
49
50
51
52
# File 'lib/skyline/content/content.rb', line 48

def taggable?
  self.reflect_on_all_associations(:has_many).detect{|a| a.name == :associated_tags}
#      rescue
#        false
end