Class: ASpaceExport::ExportModel
- Inherits:
-
Object
- Object
- ASpaceExport::ExportModel
show all
- Defined in:
- backend/app/exporters/lib/exporter.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.inherited(subclass) ⇒ Object
132
133
134
|
# File 'backend/app/exporters/lib/exporter.rb', line 132
def self.inherited(subclass)
ASpaceExport.register_model(subclass)
end
|
.model_for(name) ⇒ Object
137
138
139
|
# File 'backend/app/exporters/lib/exporter.rb', line 137
def self.model_for(name)
@model_for = name
end
|
.model_for?(name) ⇒ Boolean
142
143
144
|
# File 'backend/app/exporters/lib/exporter.rb', line 142
def self.model_for?(name)
@model_for == name
end
|
Instance Method Details
#apply_map(obj, map, opts = {}) ⇒ Object
147
148
149
150
151
152
153
154
155
156
157
158
159
160
|
# File 'backend/app/exporters/lib/exporter.rb', line 147
def apply_map(obj, map, opts = {})
fields_to_ignore = opts[:ignore] ||= []
map.each do |as_field, handler|
next if fields_to_ignore.include? as_field
fieldable = [as_field].flatten.reject { |asf| !obj.respond_to?(asf) }
next if fieldable.empty?
handler_args = fieldable.map {|f| obj.send(f) }
[handler].flatten.each {|h| self.send(h, *handler_args) }
end
end
|