Class: Excalibur::Configuration
- Inherits:
-
Object
- Object
- Excalibur::Configuration
- Includes:
- Duplicator
- Defined in:
- lib/excalibur/configuration.rb
Overview
the Configuration class is responsible for holding the configurable data and logic that will be passed down
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#meta_tags ⇒ Object
Returns the value of attribute meta_tags.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
- #dup ⇒ Object
-
#initialize(title = TruncateableContent.new, description = TruncateableContent.new, meta_tags = ::HashWithIndifferentAccess.new({})) ⇒ Configuration
constructor
A new instance of Configuration.
- #merge!(obj) ⇒ Object
- #remove_meta_tag(type, name) ⇒ Object
- #set_meta_tag(type, name, value = nil) ⇒ Object
Methods included from Duplicator
Constructor Details
#initialize(title = TruncateableContent.new, description = TruncateableContent.new, meta_tags = ::HashWithIndifferentAccess.new({})) ⇒ Configuration
Returns a new instance of Configuration.
11 12 13 14 15 16 17 18 |
# File 'lib/excalibur/configuration.rb', line 11 def initialize( title = TruncateableContent.new, description = TruncateableContent.new, = ::HashWithIndifferentAccess.new({})) @title = title @description = description @meta_tags = end |
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
8 9 10 |
# File 'lib/excalibur/configuration.rb', line 8 def description @description end |
#meta_tags ⇒ Object
Returns the value of attribute meta_tags.
9 10 11 |
# File 'lib/excalibur/configuration.rb', line 9 def @meta_tags end |
#title ⇒ Object
Returns the value of attribute title.
7 8 9 |
# File 'lib/excalibur/configuration.rb', line 7 def title @title end |
Instance Method Details
#dup ⇒ Object
33 34 35 36 37 38 |
# File 'lib/excalibur/configuration.rb', line 33 def dup self.class.new( dup_instance(@title), dup_instance(@description.dup), dup_instance(@meta_tags.dup)) end |
#merge!(obj) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/excalibur/configuration.rb', line 20 def merge!(obj) if obj.is_a? Configuration @title = merge_instance(@title, obj.title) @description = merge_instance(@description, obj.description) @meta_tags = merge_instance(@meta_tags, obj.) self else fail(TypeError.new(true), 'can only merge two Excalibur::Configuration objects') end end |
#remove_meta_tag(type, name) ⇒ Object
48 49 50 51 |
# File 'lib/excalibur/configuration.rb', line 48 def (type, name) @meta_tags[type].delete(name) if @meta_tags[type].present? @meta_tags.delete(type) if @meta_tags[type].empty? end |
#set_meta_tag(type, name, value = nil) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/excalibur/configuration.rb', line 40 def (type, name, value = nil) if @meta_tags[type].nil? @meta_tags[type] = ::HashWithIndifferentAccess.new end @meta_tags[type][name] = value end |