Sha256: 823ad193dc2677274fd5f2ffcb87c4a2ea9835bb79f2545168279d381dced0d5
Contents?: true
Size: 830 Bytes
Versions: 3
Compression:
Stored size: 830 Bytes
Contents
module ActiveModel class Exporter class << self attr_accessor :_attributes def inherited(base) base._attributes = (_attributes || []).dup end def attributes(*attrs) @_attributes.concat(attrs) end def exporter_for(resource) "#{resource.class.name}Exporter".safe_constantize end end attr_reader :object, :scope def initialize(object, options = {}) @object = object @scope = options[:scope] end def values attrs = filter(attributes) attributes.map do |attr| if attrs.include?(attr) next send(attr) if respond_to?(attr) object.send(attr) end end end def filter(attrs) attrs end def attributes self.class._attributes.dup end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
active_model_exporters-0.7.0 | lib/active_model/exporter.rb |
active_model_exporters-0.6.0 | lib/active_model/exporter.rb |
active_model_exporters-0.5.2 | lib/active_model/exporter.rb |