module GoldenFleece::Context::Export

Public Instance Methods

export(record, export_attributes) click to toggle source
# File lib/golden_fleece/context/export.rb, line 4
def export(record, export_attributes)
  export_attributes = Array.wrap export_attributes

  schemas.reduce({}) { |memo, (attribute, schema)|
    if export_attributes.include? attribute
      memo[attribute] = schema.reduce({}) { |memo, (schema_name, schema)|
        memo[schema_name.to_s] = schema.value.compute(record)
        memo
      }
    end
    memo
  }
end