Class: ActiveAdmin::Cms::Recipe
Defined Under Namespace
Classes: Ingredient, Section
Instance Attribute Summary
#parent
Class Method Summary
collapse
Instance Method Summary
collapse
#add_fields_to, #ingredient, #ingredients, #method_missing, #section, #section_id, #section_key, #sections
Class Method Details
.define(&definition_block) ⇒ Object
9
10
11
12
13
|
# File 'lib/active_admin/cms/recipe.rb', line 9
def self.define(&definition_block)
after_initialize do
define &definition_block
end
end
|
Instance Method Details
#admin_fieldset_title ⇒ Object
19
20
21
|
# File 'lib/active_admin/cms/recipe.rb', line 19
def admin_fieldset_title
'Content'
end
|
#contains_content_key?(content_key) ⇒ Boolean
23
24
25
|
# File 'lib/active_admin/cms/recipe.rb', line 23
def contains_content_key? content_key
!!ingredient_for(content_key)
end
|
#define(&block) ⇒ Object
15
16
17
|
# File 'lib/active_admin/cms/recipe.rb', line 15
def define(&block)
self.instance_eval &block
end
|
#ingredient_for(content_key) ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/active_admin/cms/recipe.rb', line 27
def ingredient_for content_key
section_keys = content_key.split ':'
current_section = self
section_keys.each do |section_id|
if section_id == section_keys.last
return current_section.ingredients[section_id.to_sym]
else
if current_section.sections[section_id.to_sym]
current_section = current_section.sections[section_id.to_sym]
else
return nil
end
end
end
end
|