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 10 def attributes(*attrs) @_attributes.concat(attrs) end
exporter_for(resource)
click to toggle source
# File lib/active_model/exporter.rb, line 14 def exporter_for(resource) "#{resource.class.name}Exporter".safe_constantize end
inherited(base)
click to toggle source
# File lib/active_model/exporter.rb, line 6 def inherited(base) base._attributes = (_attributes || []).dup end
new(object, options = {})
click to toggle source
# File lib/active_model/exporter.rb, line 22 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 41 def attributes self.class._attributes.dup end
filter(attrs)
click to toggle source
# File lib/active_model/exporter.rb, line 37 def filter(attrs) attrs end
values()
click to toggle source
# File lib/active_model/exporter.rb, line 27 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