class Promethee::Data::Master
Public Class Methods
new(data)
click to toggle source
Calls superclass method
Promethee::Data::new
# File lib/promethee/data/master.rb, line 2 def initialize(data) super data fix_master_integrity end
Public Instance Methods
flat()
click to toggle source
# File lib/promethee/data/master.rb, line 7 def flat flatten_components @data end
Protected Instance Methods
fix_master_integrity()
click to toggle source
# File lib/promethee/data/master.rb, line 13 def fix_master_integrity @data[:version] = 1 unless @data.include? :version @data[:children] = [] unless @data.include? :children end
flatten_components(component)
click to toggle source
Takes an array of components and puts every component and their children into a unique flat array
# File lib/promethee/data/master.rb, line 19 def flatten_components(component) flat_components = [component.except(:children)] (component[:children] || []).reduce flat_components do |flat_components, component| flat_components + flatten_components(component) end end