Class: DbAgent::Viewpoint::TypeCheck

Inherits:
Object
  • Object
show all
Defined in:
lib/db_agent/viewpoint/typecheck.rb

Overview

Forces typechecking on all child relations.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(db, child = nil) ⇒ TypeCheck

Returns a new instance of TypeCheck.



6
7
8
9
# File 'lib/db_agent/viewpoint/typecheck.rb', line 6

def initialize(db, child = nil)
  @db = db
  @child = child || DbAgent::Viewpoint::Base.new(db)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &bl) ⇒ Object



12
13
14
15
# File 'lib/db_agent/viewpoint/typecheck.rb', line 12

def method_missing(name, *args, &bl)
  return super unless args.empty? && bl.nil?
  child.send(name).with_typecheck
end

Instance Attribute Details

#childObject (readonly)

Returns the value of attribute child.



10
11
12
# File 'lib/db_agent/viewpoint/typecheck.rb', line 10

def child
  @child
end

#dbObject (readonly)

Returns the value of attribute db.



10
11
12
# File 'lib/db_agent/viewpoint/typecheck.rb', line 10

def db
  @db
end