class Atheme::EntityBase
Attributes
token[R]
Public Class Methods
new(session, hash_or_token) { |self| ... }
click to toggle source
# File lib/atheme/entity.rb, line 5 def initialize(session, hash_or_token) @session = session if hash_or_token.kind_of?(Hash) @updated = true hash_or_token.each do |k, v| self.instance_variable_set("@#{k}".to_sym, v) define_singleton_method(k) { v } end else @updated = false @token = hash_or_token end yield self if block_given? end
Public Instance Methods
error?()
click to toggle source
# File lib/atheme/entity.rb, line 33 def error? false end
fetch!()
click to toggle source
# File lib/atheme/entity.rb, line 29 def fetch! raise "#{self} does not know how to update itself. Slap the developer!" end
method_missing(meth, *args, &block)
click to toggle source
Calls superclass method
# File lib/atheme/entity.rb, line 21 def method_missing(meth, *args, &block) super if @updated || !fetchable? do_fetch! self.send(meth, *args, &block) end
success?()
click to toggle source
# File lib/atheme/entity.rb, line 37 def success? true end
to_ary()
click to toggle source
# File lib/atheme/entity.rb, line 27 def to_ary; end
Private Instance Methods
do_fetch!()
click to toggle source
# File lib/atheme/entity.rb, line 41 def do_fetch! @updated = true result = fetch! result.instance_variables.each do |key| next if [:@session, :@updated, :@token].include? key v = result.instance_variable_get(key) self.instance_variable_set(key, v) define_singleton_method(key.to_s[1..-1].to_sym) { v } end end
fetchable?()
click to toggle source
# File lib/atheme/entity.rb, line 52 def fetchable? true end
match(expression)
click to toggle source
# File lib/atheme/entity.rb, line 58 def match(expression) raw_output[expression, 1] end