Class: ODDB::Sponsor

Inherits:
Object show all
Includes:
Persistence
Defined in:
src/model/sponsor.rb,
test/test_model/sponsor.rb

Constant Summary

ODBA_SERIALIZABLE =
['@logo_filenames', '@urls', '@emails']

Constants included from Persistence

ODBA_PREDEFINE_SERIALIZABLE

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Methods included from PersistenceMethods

#checkout, #data_origin, #data_origins, #diff, #init, #nil_if_empty, #parent, #pointer_descr, #structural_ancestors, #undiffable?, #update_values

Constructor Details

- (Sponsor) initialize

A new instance of Sponsor



14
15
16
17
# File 'src/model/sponsor.rb', line 14

def initialize
  super
  @logo_filenames = {}
end

Instance Attribute Details

- (Object) company

Returns the value of attribute company



12
13
14
# File 'src/model/sponsor.rb', line 12

def company
  @company
end

- (Object) emails

Returns the value of attribute emails



12
13
14
# File 'src/model/sponsor.rb', line 12

def emails
  @emails
end

- (Object) logo_filename(language)



22
23
24
# File 'src/model/sponsor.rb', line 22

def logo_filename(language)
  @logo_filenames[language.to_sym]
end

- (Object) logo_filenames (readonly)

Returns the value of attribute logo_filenames



13
14
15
# File 'src/model/sponsor.rb', line 13

def logo_filenames
  @logo_filenames
end

Returns the value of attribute sponsor_until



12
13
14
# File 'src/model/sponsor.rb', line 12

def 
  @sponsor_until
end

- (Object) urls

Returns the value of attribute urls



12
13
14
# File 'src/model/sponsor.rb', line 12

def urls
  @urls
end

Instance Method Details

- (Object) adjust_types(values, app = nil)



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'src/model/sponsor.rb', line 35

def adjust_types(values, app=nil)
  values.each { |key, val|
    if(val.is_a?(Pointer))
      values[key] = val.resolve(app)
    else
      case key
      when :company
        values[key] = if(val.is_a? String)
          app.company_by_name(val)
        elsif(val.is_a?(Integer))
          app.company(val)
        else
          nil
        end
      when :sponsor_until
        values[key] = (val.is_a? Date) ? val : nil
      end
    end
  }
end

- (Object) company_name Also known as: name



18
19
20
# File 'src/model/sponsor.rb', line 18

def company_name
  @company.name if @company
end

- (Boolean) represents?(pac)

Returns:

  • (Boolean)


25
26
27
# File 'src/model/sponsor.rb', line 25

def represents?(pac)
  pac.respond_to?(:company) && (pac.company == @company)
end

- (Object) url(language = 'de')



28
29
30
# File 'src/model/sponsor.rb', line 28

def url(language='de')
  @urls.fetch(language.to_s, @urls['de']) if @urls
end

- (Boolean) valid?

Returns:

  • (Boolean)


31
32
33
# File 'src/model/sponsor.rb', line 31

def valid?
  @sponsor_until && @sponsor_until >= @@today
end