Module: Mongrep::Model
Overview
A mixin providing Virtus.model functionality and a recursive to_h method
Defined Under Namespace
Modules: Shell, VirtusExtensions
Class Method Summary collapse
-
.partial(*fields) ⇒ Model
Returns a new model that includes just the provided subset of fields from the original model.
Methods included from VirtusExtensions
Class Method Details
.partial(*field_names) ⇒ Model .partial(*field_names, nested_fields) ⇒ Model
Returns a new model that includes just the provided subset of fields from the original model
59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/mongrep/model.rb', line 59 def partial(*fields) class_name = "#{name}::Partial[#{fields.map(&:inspect).join(', ')}]" attributes = partial_attributes(*fields) Class.new do include Model include Shell extend Shell::ClassMethods define_singleton_method(:name) { class_name } attributes.each { |attribute| attribute_set << attribute } end end |