class MailyHerald::Context::Attributes

Public Class Methods

new(block) click to toggle source
# File lib/maily_herald/context.rb, line 48
def initialize block
  @attrs = {}
  @node = @parent_node = @attrs
  @block = block
end

Public Instance Methods

attribute(name, &block) click to toggle source
# File lib/maily_herald/context.rb, line 71
def attribute name, &block
  @node[name.to_s] = block
end
attribute_group(name) { || ... } click to toggle source
# File lib/maily_herald/context.rb, line 63
def attribute_group name, &block
  @parent_node = @node
  @parent_node[name.to_s] ||= {}
  @node = @parent_node[name.to_s]
  yield
  @node = @parent_node
end
for_drop() click to toggle source
# File lib/maily_herald/context.rb, line 75
def for_drop
  @attrs
end
method_missing(m, *args, &block) click to toggle source
# File lib/maily_herald/context.rb, line 79
def method_missing(m, *args, &block)
  true
end
setup(entity = nil, subscription = nil) click to toggle source
# File lib/maily_herald/context.rb, line 54
def setup entity = nil, subscription = nil
  if entity
    @attrs["subscription"] = Proc.new{ subscription } if subscription
    instance_exec entity, &@block
  else
    instance_eval &@block
  end
end