Class: Skyline::Content::MetaData::FieldPage
- Inherits:
-
Object
- Object
- Skyline::Content::MetaData::FieldPage
- Defined in:
- lib/skyline/content/meta_data/field_page.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#owner ⇒ Object
readonly
Returns the value of attribute owner.
Instance Method Summary collapse
- #description(v = nil) ⇒ Object
- #each_field(&block) ⇒ Object
- #field(*fields, &block) ⇒ Object
- #field_group(name, options = {}) {|field_group| ... } ⇒ Object
- #field_names ⇒ Object
- #field_order(*order) ⇒ Object
- #fields ⇒ Object
- #human_name ⇒ Object
-
#initialize(owner, name, options = {}) ⇒ FieldPage
constructor
A new instance of FieldPage.
- #title(v = nil) ⇒ Object
- #ungrouped_fields ⇒ Object
- #yield_field(field_name) {|| ... } ⇒ Object
Constructor Details
#initialize(owner, name, options = {}) ⇒ FieldPage
Returns a new instance of FieldPage.
7 8 9 10 11 12 13 |
# File 'lib/skyline/content/meta_data/field_page.rb', line 7 def initialize(owner,name,={}) @owner = owner @name = name @options = @fields = {} @ungrouped_fields = [] end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/skyline/content/meta_data/field_page.rb', line 5 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/skyline/content/meta_data/field_page.rb', line 5 def @options end |
#owner ⇒ Object (readonly)
Returns the value of attribute owner.
5 6 7 |
# File 'lib/skyline/content/meta_data/field_page.rb', line 5 def owner @owner end |
Instance Method Details
#description(v = nil) ⇒ Object
15 16 17 18 |
# File 'lib/skyline/content/meta_data/field_page.rb', line 15 def description(v=nil) @options[:description] = v if v @options[:description] end |
#each_field(&block) ⇒ Object
25 26 27 28 29 |
# File 'lib/skyline/content/meta_data/field_page.rb', line 25 def each_field(&block) self.ungrouped_fields.each do |field_name| yield_field(field_name,&block) end end |
#field(*fields, &block) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/skyline/content/meta_data/field_page.rb', line 35 def field(*fields,&block) = fields.last.kind_of?(Hash) ? fields.pop : {} fields = fields.first if fields.any? && fields.first.kind_of?(Array) fields.map do |name| @fields[name] = Field.new(.update(:name => name, :owner => self)) yield @fields[name] if block_given? @ungrouped_fields << name @fields[name] end end |
#field_group(name, options = {}) {|field_group| ... } ⇒ Object
47 48 49 50 51 52 |
# File 'lib/skyline/content/meta_data/field_page.rb', line 47 def field_group(name,={}) field_group = FieldGroup.new(.update(:owner => self, :name => name)) yield field_group if block_given? @fields[name] = field_group @ungrouped_fields << name end |
#field_names ⇒ Object
70 71 72 |
# File 'lib/skyline/content/meta_data/field_page.rb', line 70 def field_names @fields.keys end |
#field_order(*order) ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/skyline/content/meta_data/field_page.rb', line 58 def field_order(*order) if order.empty? @ungrouped_fields else end end |
#fields ⇒ Object
54 55 56 |
# File 'lib/skyline/content/meta_data/field_page.rb', line 54 def fields @fields end |
#human_name ⇒ Object
74 75 76 |
# File 'lib/skyline/content/meta_data/field_page.rb', line 74 def human_name self.title.present? ? self.title : self.name.to_s.humanize end |
#title(v = nil) ⇒ Object
20 21 22 23 |
# File 'lib/skyline/content/meta_data/field_page.rb', line 20 def title(v=nil) @options[:title] = v if v @options[:title] end |
#ungrouped_fields ⇒ Object
66 67 68 |
# File 'lib/skyline/content/meta_data/field_page.rb', line 66 def ungrouped_fields @ungrouped_fields end |
#yield_field(field_name) {|| ... } ⇒ Object
31 32 33 |
# File 'lib/skyline/content/meta_data/field_page.rb', line 31 def yield_field(field_name,&block) yield self.fields[field_name] end |