class Extentions::Collection::Presenter

Attributes

attributes[R]

Public Class Methods

new(model, attributes) click to toggle source
Calls superclass method
# File lib/extentions.rb, line 56
def initialize(model, attributes)
  @attributes = attributes
  super(model)
  # TODO is this really needed?
  __getobj__.pointer = self if __getobj__.respond_to? :pointer=
end

Public Instance Methods

__class__()
Alias for: class
cached() click to toggle source
# File lib/extentions.rb, line 79
def cached
  @cached ||= {}
end
class() click to toggle source
# File lib/extentions.rb, line 75
def class
  __getobj__.class
end
Also aliased as: __class__
method_missing(method, *args, &block) click to toggle source

TODO lazy init

Calls superclass method
# File lib/extentions.rb, line 64
def method_missing(method, *args, &block)
  return cached[method] if cached.include? method

  if attributes.include? method
    @cached[method] = attributes[method].call.to_s.html_safe
  else
    super
  end
end