class Structural::Hashifier

Public Class Methods

as_data(v) click to toggle source
# File lib/structural/hashifier.rb, line 11
def self.as_data(v)
  case v
  when Structural::Model then v.data
  when Array then v.first.is_a?(Structural::Model) ? v.map(&:data) : v
  else v end
end
hashify(data) click to toggle source
# File lib/structural/hashifier.rb, line 3
def self.hashify(data)
  {}.tap do |hash|
    data.each do |key, value|
      hash[key.to_sym] = as_data(value)
    end
  end
end