Module: Skyline::Content::Content::KlassMethods
- Defined in:
- lib/skyline/content/content.rb
Overview
:nodoc:
Instance Method Summary collapse
- #content? ⇒ Boolean
-
#count_for_cms(*args) ⇒ Object
Same as find_for_cms but this method only returns a count.
-
#exportable? ⇒ Boolean
Is this object exportable.
-
#filterable? ⇒ Boolean
Is this object filterable? Basically means wether or not this object has fields with the metadata :filter set to true.
-
#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.
-
#importable? ⇒ Boolean
Is this object importable.
-
#orderable? ⇒ Boolean
Does this object have a position field.
-
#paginate_for_cms(*args) ⇒ Object
Same as find_for_cms, but works with the will_paginate plugin –.
-
#publishable? ⇒ Boolean
Does this object have a published field.
-
#taggable? ⇒ Boolean
Does this object have tags.
Instance Method Details
#content? ⇒ 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) , = (args) with_skyline_scope() do count(*(args << )) end end |
#exportable? ⇒ Boolean
Is this object exportable
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.
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) , = (args) with_skyline_scope() do .update(:order => self.default_order_by_statement) find(*(args << )) end end |
#importable? ⇒ Boolean
Is this object importable
72 73 74 |
# File 'lib/skyline/content/content.rb', line 72 def importable? false end |
#orderable? ⇒ Boolean
Does this object have a position field
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) , = (args) with_skyline_scope() do .update(:order => self.default_order_by_statement) paginate(*(args << )) end end |
#publishable? ⇒ Boolean
Does this object have a published field
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
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 |