Class: MailyHerald::Context::Drop

Inherits:
Liquid::Drop
  • Object
show all
Defined in:
lib/maily_herald/context.rb

Overview

Context Attributes drop definition for Liquid

Instance Method Summary collapse

Constructor Details

#initialize(attrs) ⇒ Drop

Returns a new instance of Drop



20
21
22
# File 'lib/maily_herald/context.rb', line 20

def initialize attrs
  @attrs = attrs
end

Instance Method Details

#has_key?(name) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
27
28
# File 'lib/maily_herald/context.rb', line 24

def has_key?(name)
  name = name.to_s

  @attrs.has_key? name
end

#invoke_drop(name) ⇒ Object Also known as: []



30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/maily_herald/context.rb', line 30

def invoke_drop name
  name = name.to_s

  if @attrs.has_key? name
    if @attrs[name].is_a? Hash
      Drop.new(@attrs[name])
    else
      @attrs[name].call
    end
  else
    nil
  end
end