Module: Skyline::Content::ClassMetaData

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

Instance Method Summary collapse

Instance Method Details

#default_order_by_statementObject

Returns the default_order_by_statement



22
23
24
# File 'lib/skyline/content/class_meta_data.rb', line 22

def default_order_by_statement #:nodoc:
  self.settings.order_by || "id ASC"
end

#hidden?(scope = :menu) ⇒ Boolean

Is this a hidden class within the asked scope? Currently scope is always :menu

Returns:

  • (Boolean)


16
17
18
# File 'lib/skyline/content/class_meta_data.rb', line 16

def hidden?(scope=:menu)
  self.settings.hidden == true || self.settings.hidden.kind_of?(Array) && self.settings.hidden.include?(scope)
end

#plural_nameObject

Returns plural name of this class, falls back on standard Rails humanization



10
11
12
# File 'lib/skyline/content/class_meta_data.rb', line 10

def plural_name
  self.settings.plural_label
end

#settings(settings = nil) {|s| ... } ⇒ Object

General purpose method to set all kind of class options. Works with hashes and blocks:

settings :label => ["label","labels"]

settings do |o|
  o.label = ["label","labels"]
end

Options available

label

Parameters can be an array having 2 elements [“singular”, “plural”] or just a string, in which case it’s assumed to be just singular.

return_to_self_after_save

Define wether or not after a save operation this object should return to itself or to the listview. Defaults to return to listview (false/nil)

identification_columns

An array describing the columns this object can be described with, the values of these columns are joined with spaces. Parameter accepts also a single column name defaults to the first available of possible_identification_columns.

hidden

One or more of the following: [:menu] or just true for all of the aforementioned

presenter

The presenter to use in the listview defaults to :table, only other option is :article at the moment. Use :article to make list orderable.

order_by

The default order of this model. Just a regular SQL order_by clause, can be a string or a symbol.

orderable

Make this object act as an orderable list. If set to true, model should contain a field named :position. Also, a hash can be passed of the form => “position”, :scope => :document. In this case, articles that belong to a document can be sorted using their position to store order, and sorting will take place only within one document

Presenters

Article

Displays a list with a Title and Subtitle and some fields (be warned this should be no more than 2 or 3). The article presenter also alows drag and drop ordering if orderable is enabled.

Extra options for the article presenter are:

title_field

The field that should be used as a title in the list (defaults to first editable field if not specified)

subtitle_field

The field that should be used as a subtitle in the list (defaults to nothing)

Table

The default table presenter. No extra options required. -

Yields:

  • (s)


71
72
73
74
75
76
77
78
# File 'lib/skyline/content/class_meta_data.rb', line 71

def settings(settings=nil,&block)
  return get_settings if settings.nil? && !block_given?
  s = MetaData::ClassSettings.new(settings.update(:owner => self))
  yield s if block_given?
  write_inheritable_attribute(:settings,s)
  after_set_settings!
  s
end

#singular_nameObject

Returns singular name of this class, falls back on standard Rails humanization



5
6
7
# File 'lib/skyline/content/class_meta_data.rb', line 5

def singular_name
  self.settings.singular_label
end