class ActiveModel::Exporter
Constants
- TYPES
- VERSION
Attributes
_attributes[RW]
object[R]
scope[R]
Public Class Methods
attributes(*attrs)
click to toggle source
# File lib/active_model/exporter.rb, line 13 def attributes(*attrs) @_attributes.concat(attrs) end
exporter_for(resource)
click to toggle source
# File lib/active_model/exporter.rb, line 17 def exporter_for(resource) "#{resource.class.name}Exporter".safe_constantize end
inherited(base)
click to toggle source
Calls superclass method
# File lib/active_model/exporter.rb, line 8 def inherited(base) super base._attributes = (_attributes || []).dup end
new(object, options = {})
click to toggle source
# File lib/active_model/exporter.rb, line 24 def initialize(object, options = {}) @object = object @scope = options[:scope] end
Public Instance Methods
attributes()
click to toggle source
# File lib/active_model/exporter.rb, line 43 def attributes self.class._attributes.dup end
filter(attrs)
click to toggle source
# File lib/active_model/exporter.rb, line 39 def filter(attrs) attrs end
values()
click to toggle source
# File lib/active_model/exporter.rb, line 29 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