Class: OnsOpenApi::Dimension
- Inherits:
-
Object
- Object
- OnsOpenApi::Dimension
- Includes:
- Morph
- Defined in:
- lib/ons_openapi/dimension.rb
Instance Method Summary collapse
Instance Method Details
#labels ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/ons_openapi/dimension.rb', line 11 def labels data = values non_data_keys = role.morph_attributes.values.flatten.map{|x| alt_label x} non_data_keys.each do |k| data.delete(k) end data = data.values.first.category key_to_index = data.index.morph_attributes key_to_label = data.label.morph_attributes labels = key_to_index.to_a.each_with_object([]) do |k_i, a| if index = k_i[1] key = k_i[0] a[index] = key_to_label[key] end end # label = data.label # items = data.category.index # labels = data.category.label end |
#values ⇒ Object
5 6 7 8 9 |
# File 'lib/ons_openapi/dimension.rb', line 5 def values ids.each_with_object({}) do |x, h| h[alt_label(x)] = send(method(x)) end end |