Module: AssOle::DSL

Included in:
Module
Defined in:
lib/ass_ole/dsl.rb

Overview

It mixins for Module

Instance Method Summary collapse

Instance Method Details

#is_ole_runtime(type) ⇒ Object

Define Ole runtime

Examples:

acct_infobase = AssMaintainer::InfoBase.new('name', 'File="path"')

module AccountingExternal
  is_ole_runtime :external
end

AccountingExternal.run acct_infobase

module MyScript
  like_ole_runtime acct_infobase

  def self.version
    Metadata.Version
  end
end

puts MyScript.version


104
105
106
107
108
109
110
111
112
113
114
# File 'lib/ass_ole/dsl.rb', line 104

def is_ole_runtime(type)
  fail 'Ole runtime is a Module not a Class' if self.class == Class
  case type
  when :external then extend AssOle::Runtimes::App::External
  when :thick then extend AssOle::Runtimes::App::Thick
  when :thin then extend AssOle::Runtimes::App::Thin
  when :wp then extend AssOle::Runtimes::Claster::Wp
  when :agent then extend AssOle::Runtimes::Claster::Agent
  else fail "Invalid runtime #{type}"
  end
end

#is_ole_snippetObject

Define module as Ole snippet

Examples:

module Query
  is_ole_snippet

  def execute(query)
    q = newObject 'Query', query
    q.exequte
  end
end

class MyOleAccessor
  it_has_ole_runtime
  like_ole_runtime external_connection

  include Query

  def get_foo
    text = 'select * from foo where bar'
    result = execute text
  end
end

MyOleAccessor.new.get_foo


30
31
32
33
34
# File 'lib/ass_ole/dsl.rb', line 30

def is_ole_snippet
  fail 'Ole snippet must be a Module not a Class' if\
    self.class == Class
  extend AssOle::Snippets::IsSnippet
end

#it_has_ole_runtime(runtime) ⇒ Object

Define class or module wich include Ole runtime

Examples:

info_base = AssMaintainer::InfoBase.new('', 'File="path"')
class MyOleAccessor
  it_has_ole_runtime thick_app

  thick_app.run info_base

  def hello(s)
    ole_connector.sTring s
  end
end

MyOleAccessor.hello('Ass')


74
75
76
77
78
79
80
81
# File 'lib/ass_ole/dsl.rb', line 74

def it_has_ole_runtime(runtime)
  case self
  when Class then
    include runtime
  else
    extend runtime
  end
end

#like_ole_runtime(runtime) ⇒ Object

Define class or module which transparent call Ole runtime as self

Examples:

info_base = AssMaintainer::InfoBase.new('', 'File="path"')
class MyOleAccessor
  like_ole_runtime thick_app

  thick_app.run info_base

  def hello(s)
    sTring s
  end
end

MyOleAccessor.hello('Ass')


50
51
52
53
54
55
56
57
58
# File 'lib/ass_ole/dsl.rb', line 50

def like_ole_runtime(runtime)
  it_has_ole_runtime runtime
  case self
  when Class then
    include AssOle::Snippets::LikeOleRuntime
  else
    extend AssOle::Snippets::LikeOleRuntime
  end
end