Class: Mappum::FieldMap

Inherits:
Map show all
Defined in:
lib/mappum/map.rb

Instance Attribute Summary collapse

Attributes inherited from Map

#bidi_maps, #maps, #source, #src_ref, #strip_empty

Instance Method Summary collapse

Methods inherited from Map

#initialize, #strip_empty?

Constructor Details

This class inherits a constructor from Mappum::Map

Instance Attribute Details

#blockObject

Returns the value of attribute block.



95
96
97
# File 'lib/mappum/map.rb', line 95

def block
  @block
end

#descObject

Returns the value of attribute desc.



95
96
97
# File 'lib/mappum/map.rb', line 95

def desc
  @desc
end

#dictObject

Returns the value of attribute dict.



95
96
97
# File 'lib/mappum/map.rb', line 95

def dict
  @dict
end

#fromObject

Returns the value of attribute from.



95
96
97
# File 'lib/mappum/map.rb', line 95

def from
  @from
end

#funcObject

Returns the value of attribute func.



95
96
97
# File 'lib/mappum/map.rb', line 95

def func
  @func
end

#func_on_nilObject

Returns the value of attribute func_on_nil.



95
96
97
# File 'lib/mappum/map.rb', line 95

def func_on_nil
  @func_on_nil
end

#l2r_nameObject

Returns the value of attribute l2r_name.



96
97
98
# File 'lib/mappum/map.rb', line 96

def l2r_name
  @l2r_name
end

#leftObject

Returns the value of attribute left.



95
96
97
# File 'lib/mappum/map.rb', line 95

def left
  @left
end

#map_whenObject

Returns the value of attribute map_when.



96
97
98
# File 'lib/mappum/map.rb', line 96

def map_when
  @map_when
end

#nameObject

Returns the value of attribute name.



96
97
98
# File 'lib/mappum/map.rb', line 96

def name
  @name
end

#name_prefixObject

Returns the value of attribute name_prefix.



96
97
98
# File 'lib/mappum/map.rb', line 96

def name_prefix
  @name_prefix
end

#r2l_nameObject

Returns the value of attribute r2l_name.



96
97
98
# File 'lib/mappum/map.rb', line 96

def r2l_name
  @r2l_name
end

#rightObject

Returns the value of attribute right.



95
96
97
# File 'lib/mappum/map.rb', line 95

def right
  @right
end

#submap_aliasObject

Returns the value of attribute submap_alias.



95
96
97
# File 'lib/mappum/map.rb', line 95

def submap_alias
  @submap_alias
end

#toObject

Returns the value of attribute to.



95
96
97
# File 'lib/mappum/map.rb', line 95

def to
  @to
end

#to_array_takeObject

Returns the value of attribute to_array_take.



97
98
99
# File 'lib/mappum/map.rb', line 97

def to_array_take
  @to_array_take
end

#to_array_take_l2rObject

Returns the value of attribute to_array_take_l2r.



97
98
99
# File 'lib/mappum/map.rb', line 97

def to_array_take_l2r
  @to_array_take_l2r
end

#to_array_take_r2lObject

Returns the value of attribute to_array_take_r2l.



97
98
99
# File 'lib/mappum/map.rb', line 97

def to_array_take_r2l
  @to_array_take_r2l
end

#when_l2rObject

Returns the value of attribute when_l2r.



96
97
98
# File 'lib/mappum/map.rb', line 96

def when_l2r
  @when_l2r
end

#when_r2lObject

Returns the value of attribute when_r2l.



96
97
98
# File 'lib/mappum/map.rb', line 96

def when_r2l
  @when_r2l
end

Instance Method Details

#func_on_nil?Boolean

Returns:



154
155
156
# File 'lib/mappum/map.rb', line 154

def func_on_nil?
  @func_on_nil
end

#normalizeObject



112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# File 'lib/mappum/map.rb', line 112

def normalize
  #if bidirectional
  if not normalized?
    map_r2l = self.clone
    map_r2l.to = self.left
    map_r2l.from = self.right
    map_r2l.name = self.r2l_name
    map_r2l.r2l_name, map_r2l.l2r_name = nil, nil
    map_r2l.map_when = self.when_r2l
    map_r2l.when_r2l, map_r2l.when_l2r = nil, nil
    map_r2l.to_array_take = self.to_array_take_r2l
    map_r2l.to_array_take_r2l, map_r2l.to_array_take_l2r = nil, nil

    
    map_r2l.dict = self.dict.invert unless self.dict.nil?
  
    map_l2r = self.clone
    map_l2r.to = self.right
    map_l2r.from = self.left
    map_l2r.name = self.l2r_name
    map_l2r.r2l_name, map_l2r.l2r_name = nil, nil
    map_l2r.map_when = self.when_l2r
    map_l2r.when_r2l, map_l2r.when_l2r = nil, nil
    map_l2r.to_array_take = self.to_array_take_l2r
    map_l2r.to_array_take_r2l, map_l2r.to_array_take_l2r = nil, nil
    
    map_r2l.maps = self.maps.select do |m|
      m.to.parent == map_r2l.to or m.to.parent.kind_of? Context
    end
    map_l2r.maps = self.maps.select do |m|
      m.to.parent == map_l2r.to or m.to.parent.kind_of? Context
    end
  
    [map_r2l, map_l2r]
  else
    [self]
  end 
end

#normalized?Boolean

True if map is unidirectional. Map is unidirectional when maps one way only.

Returns:



100
101
102
# File 'lib/mappum/map.rb', line 100

def normalized?
  not @from.nil?
end

#simple?Boolean

Returns:



150
151
152
153
# File 'lib/mappum/map.rb', line 150

def simple?
    @func.nil? && @dict.nil? && @desc.nil? && 
      @maps.empty? && @bidi_maps.empty? && @right.func.nil? && @left.func.nil?
end