Sha256: 1e2e6f686f3d109e279772d76fc2a94ab4c10565a3b856894c2f0e2fe5e3344a

Contents?: true

Size: 659 Bytes

Versions: 21

Compression:

Stored size: 659 Bytes

Contents

# frozen_string_literal: true

class MyParser
  include Arstotzka

  expose :id
  expose :name, :age, path: :person
  expose :total_money, full_path: 'accounts.balance', after: :sum,
                       cached: true, type: :money_float
  expose :total_owed, full_path: 'loans.value', after: :sum,
                      cached: true, type: :money_float

  attr_reader :json

  def initialize(json = {})
    @json = json
  end

  private

  def sum(balances)
    balances&.sum
  end

  models = File.expand_path('spec/support/models/my_parser/*.rb')
  Dir[models].each do |file|
    autoload file.gsub(%r{.*\/(.*)\..*}, '\1').camelize.to_sym, file
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
arstotzka-1.6.2 spec/support/models/my_parser.rb
arstotzka-1.6.1 spec/support/models/my_parser.rb
arstotzka-1.6.0 spec/support/models/my_parser.rb
arstotzka-1.5.0 spec/support/models/my_parser.rb
arstotzka-1.4.4 spec/support/models/my_parser.rb
arstotzka-1.4.3 spec/support/models/my_parser.rb
arstotzka-1.4.2 spec/support/models/my_parser.rb
arstotzka-1.4.1 spec/support/models/my_parser.rb
arstotzka-1.4.0 spec/support/models/my_parser.rb
arstotzka-1.3.2 spec/support/models/my_parser.rb
arstotzka-1.3.1 spec/support/models/my_parser.rb
arstotzka-1.3.0 spec/support/models/my_parser.rb
arstotzka-1.2.4 spec/support/models/my_parser.rb
arstotzka-1.2.3 spec/support/models/my_parser.rb
arstotzka-1.2.2 spec/support/models/my_parser.rb
arstotzka-1.2.1 spec/support/models/my_parser.rb
arstotzka-1.2.0 spec/support/models/my_parser.rb
arstotzka-1.1.0 spec/support/models/my_parser.rb
arstotzka-1.0.4 spec/support/models/my_parser.rb
arstotzka-1.0.3 spec/support/models/my_parser.rb