module Ruhoh::Base::Modelable
Public Class Methods
included(klass)
click to toggle source
# File lib/ruhoh/base/modelable.rb, line 4 def self.included(klass) klass.__send__(:attr_reader, :pointer, :ruhoh) end
new(ruhoh, pointer)
click to toggle source
# File lib/ruhoh/base/modelable.rb, line 8 def initialize(ruhoh, pointer) raise "Cannot instantiate a model with a nil pointer" unless pointer @ruhoh = ruhoh @pointer = pointer end
Public Instance Methods
collection()
click to toggle source
# File lib/ruhoh/base/modelable.rb, line 28 def collection @ruhoh.collection(@pointer['resource']) end
content()
click to toggle source
@returns Raw (unconverted) page content
# File lib/ruhoh/base/modelable.rb, line 22 def content return @content if @content process @content || '' end
data()
click to toggle source
@returns[Hash Object] Top page metadata
# File lib/ruhoh/base/modelable.rb, line 15 def data return @data if @data process @data || {} end
process()
click to toggle source
Override this to process custom data
# File lib/ruhoh/base/modelable.rb, line 33 def process changed notify_observers(@pointer) @pointer end
try(method)
click to toggle source
# File lib/ruhoh/base/modelable.rb, line 39 def try(method) return __send__(method) if respond_to?(method) return data[method.to_s] if data.key?(method.to_s) false end