Class: EPlat::Mapping::Base
- Inherits:
-
Object
- Object
- EPlat::Mapping::Base
show all
- Defined in:
- lib/e_plat/mapping/base.rb
Instance Method Summary
collapse
Instance Method Details
#aliases ⇒ Object
24
25
26
27
28
29
30
31
|
# File 'lib/e_plat/mapping/base.rb', line 24
def aliases
native_attribute_aliases.map do |alias_hash|
next unless alias_hash[:alias_attribute]
keys = alias_hash[:alias_attribute].values[0..1]
Hash[*keys]
end.compact_blank.inject(&:merge) || {}
end
|
#mappable_keys ⇒ Object
43
44
45
|
# File 'lib/e_plat/mapping/base.rb', line 43
def mappable_keys
native_attribute_aliases.map{|a| a.values.first[:e_plat_key]}.presence || :all
end
|
#native_attribute_aliases ⇒ Object
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/e_plat/mapping/base.rb', line 13
def native_attribute_aliases
[
]
end
|
#native_attributes ⇒ Object
9
10
11
|
# File 'lib/e_plat/mapping/base.rb', line 9
def native_attributes
[]
end
|
#native_top_key ⇒ Object
5
6
7
|
# File 'lib/e_plat/mapping/base.rb', line 5
def native_top_key
:itself end
|
#to_e_plat_keys(attributes) ⇒ Object
38
39
40
41
|
# File 'lib/e_plat/mapping/base.rb', line 38
def to_e_plat_keys(attributes)
as = aliases
attributes.transform_keys{|key| (as[key]) ? as[key] : key }
end
|
#to_native_keys(attributes) ⇒ Object
33
34
35
36
|
# File 'lib/e_plat/mapping/base.rb', line 33
def to_native_keys(attributes)
as = aliases.invert
attributes.transform_keys{|key| (as[key]) ? as[key] : key }
end
|