Class: ODDB::Migel::Subgroup

Inherits:
Object
  • Object
show all
Includes:
SimpleLanguage
Defined in:
src/model/migel/subgroup.rb

Constant Summary

ODBA_SERIALIZABLE =
['@descriptions']

Constants included from Persistence

ODBA_PREDEFINE_SERIALIZABLE

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Methods included from SimpleLanguage

#description, #descriptions, #has_description?, #match, #method_missing, #respond_to?, #search_text, #to_s, #update_values

Methods included from PersistenceMethods

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

Constructor Details

- (Subgroup) initialize(code)

A new instance of Subgroup



18
19
20
21
# File 'src/model/migel/subgroup.rb', line 18

def initialize(code)
  @products = {}
  @code = code
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ODDB::SimpleLanguage

Instance Attribute Details

- (Object) code (readonly) Also known as: pointer_descr

Returns the value of attribute code



16
17
18
# File 'src/model/migel/subgroup.rb', line 16

def code
  @code
end

- (Object) group

Returns the value of attribute group



15
16
17
# File 'src/model/migel/subgroup.rb', line 15

def group
  @group
end

- (Object) limitation_text (readonly)

Returns the value of attribute limitation_text



16
17
18
# File 'src/model/migel/subgroup.rb', line 16

def limitation_text
  @limitation_text
end

- (Object) products (readonly)

Returns the value of attribute products



16
17
18
# File 'src/model/migel/subgroup.rb', line 16

def products
  @products
end

- (Object) subgroup (readonly)

Returns the value of attribute subgroup



16
17
18
# File 'src/model/migel/subgroup.rb', line 16

def subgroup
  @subgroup
end

Instance Method Details

- (Object) checkout



22
23
24
25
26
# File 'src/model/migel/subgroup.rb', line 22

def checkout
  raise "cannot delete nonempty subgroup" unless(@products.empty?)
  @products.odba_delete
  @limitation_text.odba_delete unless(@limitation_text.nil?)
end

- (Object) create_limitation_text



27
28
29
# File 'src/model/migel/subgroup.rb', line 27

def create_limitation_text
  @limitation_text = LimitationText.new
end

- (Object) create_product(productcd)



30
31
32
33
34
# File 'src/model/migel/subgroup.rb', line 30

def create_product(productcd)
  product = Product.new(productcd)
  product.subgroup = self
  @products.store(productcd, product)
end

- (Object) delete_limitation_text



35
36
37
38
39
40
41
# File 'src/model/migel/subgroup.rb', line 35

def delete_limitation_text
  if(lt = @limitation_text)
    @limitation_text = nil
    lt.odba_delete
    lt
  end
end

- (Object) delete_product(code)



42
43
44
45
46
47
# File 'src/model/migel/subgroup.rb', line 42

def delete_product(code)
  if(prd = @products.delete(code))
    @products.odba_isolated_store
    prd
  end
end

- (Object) group_code



48
49
50
# File 'src/model/migel/subgroup.rb', line 48

def group_code
  @group.code 
end

- (Object) migel_code



51
52
53
# File 'src/model/migel/subgroup.rb', line 51

def migel_code
  [ @group.code, @code ].join('.')
end

- (Object) product(code)



54
55
56
# File 'src/model/migel/subgroup.rb', line 54

def product(code)
  @products[code]
end