Class: SkeletonLoader::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/skeleton_loader/configuration.rb

Overview

Configuration class manages settings for the SkeletonLoader gem.

Constant Summary collapse

TEMPLATE_DEFAULTS =
{
  card: { width: 200, count: 3, per_row: 3 },
  comment: { width: 900, count: 2, per_row: 1 },
  default: { width: 900, count: 1, per_row: 1 },
  gallery: { width: 320, count: 3, per_row: 3 },
  paragraph: { width: 900, count: 1, per_row: 1 },
  product: { width: 320, count: 3, per_row: 3 },
  profile: { width: 320, count: 3, per_row: 3 }
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



20
21
22
# File 'lib/skeleton_loader/configuration.rb', line 20

def initialize
  reset!
end

Instance Attribute Details

#additional_allowed_attributesObject (readonly)

Returns the value of attribute additional_allowed_attributes.



16
17
18
# File 'lib/skeleton_loader/configuration.rb', line 16

def additional_allowed_attributes
  @additional_allowed_attributes
end

#additional_allowed_css_propertiesObject (readonly)

Returns the value of attribute additional_allowed_css_properties.



16
17
18
# File 'lib/skeleton_loader/configuration.rb', line 16

def additional_allowed_css_properties
  @additional_allowed_css_properties
end

#additional_allowed_tagsObject (readonly)

Returns the value of attribute additional_allowed_tags.



16
17
18
# File 'lib/skeleton_loader/configuration.rb', line 16

def additional_allowed_tags
  @additional_allowed_tags
end

#animation_typeObject (readonly)

Returns the value of attribute animation_type.



16
17
18
# File 'lib/skeleton_loader/configuration.rb', line 16

def animation_type
  @animation_type
end

#scaleObject (readonly)

Returns the value of attribute scale.



16
17
18
# File 'lib/skeleton_loader/configuration.rb', line 16

def scale
  @scale
end

#template_pathsObject (readonly)

Returns the value of attribute template_paths.



16
17
18
# File 'lib/skeleton_loader/configuration.rb', line 16

def template_paths
  @template_paths
end

#templatesObject (readonly)

Returns the value of attribute templates.



16
17
18
# File 'lib/skeleton_loader/configuration.rb', line 16

def templates
  @templates
end

Instance Method Details

#base_optionsObject



32
33
34
35
36
37
38
39
40
# File 'lib/skeleton_loader/configuration.rb', line 32

def base_options
  {
    scale: @scale,
    animation_type: @animation_type,
    additional_allowed_tags: @additional_allowed_tags,
    additional_allowed_attributes: @additional_allowed_attributes,
    additional_allowed_css_properties: @additional_allowed_css_properties
  }
end

#reset!Object

Resets all configuration options to their defaults.



25
26
27
28
29
30
# File 'lib/skeleton_loader/configuration.rb', line 25

def reset!
  set_general_defaults
  set_template_defaults
  set_animation_defaults
  set_security_defaults
end

#template_defaults_for(type) ⇒ Object

Returns the default options for a specific template type



43
44
45
# File 'lib/skeleton_loader/configuration.rb', line 43

def template_defaults_for(type)
  @templates[type&.to_sym || :default] || @templates[:default]
end