class Tumblargh::Resource::Base

Attributes

attributes[R]
context[RW]

Needed by renderer for context propagation

Public Class Methods

new(attrs={}) click to toggle source
# File lib/tumblargh/resource/base.rb, line 9
def initialize(attrs={})
  self.attributes = attrs
end

Public Instance Methods

attributes=(attrs) click to toggle source
# File lib/tumblargh/resource/base.rb, line 15
def attributes=(attrs)
  @attributes = attrs.with_indifferent_access
end
method_missing(method_symbol, *arguments) click to toggle source
# File lib/tumblargh/resource/base.rb, line 19
def method_missing(method_symbol, *arguments)
  method_name = method_symbol.to_s

  if method_name =~ /(=|\?)$/
    case $1
    when "="
      attributes[$`] = arguments.first
    when "?"
      attributes[$`]
    end
  else
    return attributes[method_name] if attributes.include?(method_name)

    # propagating renderer context
    return context.send(method_symbol, *arguments) unless context.nil?
  end
end