Class: RBlade::SlotManager

Inherits:
Object
  • Object
show all
Defined in:
lib/rblade/helpers/slot_manager.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content, attributes = nil) ⇒ SlotManager

Returns a new instance of SlotManager.



7
8
9
10
# File 'lib/rblade/helpers/slot_manager.rb', line 7

def initialize(content, attributes = nil)
  @content = content
  @attributes = attributes && AttributesManager.new(attributes)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method) ⇒ Object



24
25
26
# File 'lib/rblade/helpers/slot_manager.rb', line 24

def method_missing(method, *)
  @content.send(method, *)
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



37
38
39
# File 'lib/rblade/helpers/slot_manager.rb', line 37

def attributes
  @attributes
end

Class Method Details

.wrap(var) ⇒ Object

Wraps var in a slot manager if it's a string



33
34
35
# File 'lib/rblade/helpers/slot_manager.rb', line 33

def self.wrap(var)
  var.is_a?(String) ? new(var) : var
end

Instance Method Details

#html_safe?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/rblade/helpers/slot_manager.rb', line 12

def html_safe?
  true
end

#respond_to_missing?(method_name, *args) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/rblade/helpers/slot_manager.rb', line 28

def respond_to_missing?(method_name, *args)
  @content.respond_to?(method_name)
end

#to_sObject



16
17
18
# File 'lib/rblade/helpers/slot_manager.rb', line 16

def to_s
  self
end

#to_strObject



20
21
22
# File 'lib/rblade/helpers/slot_manager.rb', line 20

def to_str
  @content
end