Class: DataWorks::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/data_works/base.rb

Instance Method Summary collapse

Constructor Details

#initializeBase

Returns a new instance of Base.



7
8
9
# File 'lib/data_works/base.rb', line 7

def initialize
  @works = DataWorks::Works.new
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object

we expose the public interface here



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/data_works/base.rb', line 12

def method_missing(method_name, *args, &block)
  method_name = method_name.to_s
  if method_name =~ /\A(add_|the_)(\w+)\Z/ ||
     method_name =~ /\A(\w+)(\d+)\Z/ ||
     method_name =~ /\Aset_(current_default|restriction)\Z/ ||
     method_name =~ /\Aclear_(current_default|restriction)_for\Z/ ||
     method_name == 'visualize'
    @works.send(method_name, *args, &block)
  else
    raise NoMethodError.new("#{method_name} method not found in data works")
  end
end