module Ruhoh::Base::ModelViewable

Public Class Methods

new(model) click to toggle source
Calls superclass method
# File lib/ruhoh/base/model_viewable.rb, line 2
def initialize(model)
  super(model)
  @model = model
  @ruhoh = model.ruhoh

  # Define direct access to the data Hash object
  # but don't overwrite methods if already defined.
  data.keys.each do |method|
    (class << self; self; end).class_eval do
      next if method_defined?(method)
      define_method method do |*args, &block|
        data[method]
      end
    end
  end
end

Public Instance Methods

<=>(other) click to toggle source
# File lib/ruhoh/base/model_viewable.rb, line 19
def <=>(other)
  id <=> other.id
end
[](attribute) click to toggle source
# File lib/ruhoh/base/model_viewable.rb, line 23
def [](attribute)
  __send__(attribute)
end
[]=(key, value) click to toggle source
# File lib/ruhoh/base/model_viewable.rb, line 27
def []=(key, value)
  __send__("#{key}=", value)
end