Sha256: 8b3435e097ad7461555f9db3ce9133ee98b6b75d16f633d48705aa34485e10d1

Contents?: true

Size: 499 Bytes

Versions: 12

Compression:

Stored size: 499 Bytes

Contents

class UserExporter < ActiveModel::Exporter
  attributes :first_name, :last_name, :full_name

  def full_name
    "#{object.first_name}-#{object.last_name}#{scope ? "-#{scope}" : ''}"
  end
end

class FancyUserExporter < ActiveModel::Exporter
  attributes :first_name, :last_name
end

class FilterUserExporter < ActiveModel::Exporter
  attributes :first_name, :last_name, :email

  def filter(attrs)
    if object.last_name == 'Bar1'
      attrs - [:last_name]
    else
      attrs
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
active_model_exporters-0.5.1 test/fixtures/exporters.rb
active_model_exporters-0.5.0 test/fixtures/exporters.rb
active_model_exporters-0.4.1 test/fixtures/exporters.rb
active_model_exporters-0.4.0 test/fixtures/exporters.rb
active_model_exporters-0.3.2 test/fixtures/exporters.rb
active_model_exporters-0.3.1 test/fixtures/exporters.rb
active_model_exporters-0.3.0 test/fixtures/exporters.rb
active_model_exporters-0.2.0 test/fixtures/exporters.rb
active_model_exporters-0.1.0 test/fixtures/exporters.rb
active_model_exporters-0.0.5 test/fixtures/exporters.rb
active_model_exporters-0.0.4 test/fixtures/exporters.rb
active_model_exporters-0.0.3 test/fixtures/exporters.rb