Class: ODDB::YdimPlugin::DebitorFacade

Inherits:
Object
  • Object
show all
Defined in:
src/plugin/ydim.rb

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (DebitorFacade) initialize(email, app)

A new instance of DebitorFacade



15
16
17
18
19
20
# File 'src/plugin/ydim.rb', line 15

def initialize(, app)
  @app = app
  @email = 
  @debitor = app.yus_model()
  @invoice_email = method_missing(:invoice_email) || 
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

- (Object) method_missing(method, *args, &block)



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'src/plugin/ydim.rb', line 21

def method_missing(method, *args, &block)
  res = if(@debitor.respond_to?(method))
          @debitor.send(method, *args, &block)
        else
          @app.yus_get_preference(@email, method)
        end
  if res.is_a?(String)
    begin
      res = ICONV.iconv res
    rescue Iconv::IllegalSequence
    end
  end
  res
end

Instance Attribute Details

- (Object) invoice_email (readonly)

Returns the value of attribute invoice_email



14
15
16
# File 'src/plugin/ydim.rb', line 14

def invoice_email
  @invoice_email
end

Instance Method Details

- (Object) ===(test)



43
44
45
# File 'src/plugin/ydim.rb', line 43

def ===(test)
  @debitor === test
end

- (Object) ydim_id=(id)



35
36
37
38
39
40
41
42
# File 'src/plugin/ydim.rb', line 35

def ydim_id=(id)
  if(@debitor.respond_to?(:ydim_id=))
    @debitor.ydim_id = id
    @debitor.odba_store
  else
    @app.yus_set_preference(@email, 'ydim_id', id)
  end
end