Class: Webhookdb::Message::Rendering

Inherits:
Object
  • Object
show all
Defined in:
lib/webhookdb/message.rb

Overview

String-like type representing the output of a rendering operation. Use [key] to access exposed variables, as per LiquidExpose.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(contents, exposed = {}) ⇒ Rendering

Returns a new instance of Rendering.



128
129
130
131
# File 'lib/webhookdb/message.rb', line 128

def initialize(contents, exposed={})
  @contents = contents
  @exposed = exposed
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name) ⇒ Object



146
147
148
# File 'lib/webhookdb/message.rb', line 146

def method_missing(name, *, &)
  return self.contents.respond_to?(name) ? self.contents.send(name, *, &) : super
end

Instance Attribute Details

#contentsObject (readonly)

Returns the value of attribute contents.



126
127
128
# File 'lib/webhookdb/message.rb', line 126

def contents
  @contents
end

#exposedObject (readonly)

Returns the value of attribute exposed.



126
127
128
# File 'lib/webhookdb/message.rb', line 126

def exposed
  @exposed
end

Instance Method Details

#[](key) ⇒ Object



133
134
135
# File 'lib/webhookdb/message.rb', line 133

def [](key)
  return self.exposed[key]
end

#respond_to_missing?(name, *args) ⇒ Boolean

Returns:

  • (Boolean)


141
142
143
144
# File 'lib/webhookdb/message.rb', line 141

def respond_to_missing?(name, *args)
  return true if super
  return self.contents.respond_to?(name)
end

#to_sObject



137
138
139
# File 'lib/webhookdb/message.rb', line 137

def to_s
  return self.contents
end