Method: ActiveData::Model::Associations::ReferencesMany#default
- Defined in:
- lib/active_data/model/associations/references_many.rb
#default ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/active_data/model/associations/references_many.rb', line 47 def default return [] if evar_loaded? default = Array.wrap(reflection.default(owner)) return [] unless default if default.all? { |object| object.is_a?(reflection.persistence_adapter.data_type) } default elsif default.all? { |object| object.is_a?(Hash) } default.map { |attributes| build_object(attributes) } else reflection.persistence_adapter.find_all(owner, default) end || [] end |