Sha256: 2c784cd24244ad1c69221dddf4e5d52ade26d50f6fc5f76f4fef45161b9f7ae6
Contents?: true
Size: 885 Bytes
Versions: 5
Compression:
Stored size: 885 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) attrs.each do |attr| define_method(attr) do object.send(attr) end unless method_defined?(attr) end 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 { |attr| send(attr) if attrs.include?(attr) } end def filter(attrs) attrs end def attributes self.class._attributes.dup end end end
Version data entries
5 entries across 5 versions & 1 rubygems