Methods
- A
- N
- R
- S
Included Modules
- RankedModel
Instance Public methods
attr(field)
Link
Source: show
# File app/models/cardboard/page_part.rb, line 54 def attr(field) field = field.to_s @attr ||= {} @attr[field] ||= begin f = self.fields.where(identifier: field).first return nil unless f out = f.value_uid.nil? ? nil : f.value out = f.default if f.required? && out.nil? f.type == "rich_text" ? out.try(:html_safe) : out end end
new_subpart()
Link
Source: show
# File app/models/cardboard/page_part.rb, line 39 def new_subpart return nil if !repeatable? || subpart? master = self.subparts.first subpart = master.dup for field in master.fields new_field = field.dup new_field.value = nil new_field.object_with_field_id = nil new_field.object_with_field_type = nil new_field.page_part_id = nil subpart.fields << new_field end return subpart end