Class: Smithy::PermittedParams

Inherits:
Struct
  • Object
show all
Defined in:
app/models/smithy/permitted_params.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#paramsObject

Returns the value of attribute params

Returns:

  • (Object)

    the current value of params



2
3
4
# File 'app/models/smithy/permitted_params.rb', line 2

def params
  @params
end

#userObject

Returns the value of attribute user

Returns:

  • (Object)

    the current value of user



2
3
4
# File 'app/models/smithy/permitted_params.rb', line 2

def user
  @user
end

Instance Method Details

#asset_attributesObject



15
16
17
# File 'app/models/smithy/permitted_params.rb', line 15

def asset_attributes
  [ :name, :file, :file_name, :file_url, :retained_file, :uploaded_file_url ]
end

#asset_source_attributesObject



19
20
21
# File 'app/models/smithy/permitted_params.rb', line 19

def asset_source_attributes
  [ :name, assets_files: [] ]
end

#content_attributesObject



23
24
25
# File 'app/models/smithy/permitted_params.rb', line 23

def content_attributes
  [ :content ]
end

#content_block_attributesObject



27
28
29
30
# File 'app/models/smithy/permitted_params.rb', line 27

def content_block_attributes
  # [ :name, templates_attributes: [ :id, :name, :content, :_destroy ] ]
  :all
end

#content_block_template_attributesObject



32
33
34
# File 'app/models/smithy/permitted_params.rb', line 32

def content_block_template_attributes
  [ :content, :name ]
end

#image_attributesObject



36
37
38
# File 'app/models/smithy/permitted_params.rb', line 36

def image_attributes
  [ :alternate_text, :asset_id, :height, :html_attributes, :image_scaling, :link_url, :width, :content ]
end

#page_attributesObject



40
41
42
# File 'app/models/smithy/permitted_params.rb', line 40

def page_attributes
  [ :browser_title, :cache_length, :description, :external_link, :keywords, :permalink, :publish, :published_at, :show_in_navigation, :title, :parent_id, :template_id ]
end

#page_content_attributesObject



44
45
46
47
# File 'app/models/smithy/permitted_params.rb', line 44

def page_content_attributes
  # [ :label, :container, :content_block_type, :content_block_template_id, :position ]
  :all
end

#page_list_attributesObject



49
50
51
# File 'app/models/smithy/permitted_params.rb', line 49

def page_list_attributes
  [ :count, :page_template_id, :parent_id, :include_children, :sort ]
end

#params_for(param) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
# File 'app/models/smithy/permitted_params.rb', line 3

def params_for(param)
  param = param.to_sym
  attributes = send("#{param.to_s}_attributes".to_sym)
  if attributes == :all
    params.fetch(param, {}).permit!
  elsif attributes.respond_to? :call
    attributes.call
  else
    params.fetch(param, {}).permit( *attributes )
  end
end

#setting_attributesObject



53
54
55
# File 'app/models/smithy/permitted_params.rb', line 53

def setting_attributes
  [ :name, :value ]
end

#template_attributesObject



57
58
59
# File 'app/models/smithy/permitted_params.rb', line 57

def template_attributes
  [ :name, :content, :template_type ]
end

#template_container_attributesObject



61
62
63
# File 'app/models/smithy/permitted_params.rb', line 61

def template_container_attributes
  [ :name, :position ]
end