Class: NoBrainer::Array
- Inherits:
-
Array
- Object
- Array
- NoBrainer::Array
- Defined in:
- lib/no_brainer/document/types/array.rb
Direct Known Subclasses
Class Method Summary collapse
-
.nobrainer_cast_db_to_model(values) ⇒ Object
delegate cast to each array element.
-
.nobrainer_cast_model_to_db(values) ⇒ Object
delegate cast to each array element.
-
.nobrainer_cast_user_to_model(values) ⇒ Object
delegate cast to each array element.
-
.of(object_type = nil, **options) ⇒ Object
convenience method to create a TypedArray.
Class Method Details
.nobrainer_cast_db_to_model(values) ⇒ Object
delegate cast to each array element
28 29 30 31 32 33 34 35 36 |
# File 'lib/no_brainer/document/types/array.rb', line 28 def self.nobrainer_cast_db_to_model(values) ::Array.wrap(values).map do |value| if value.class.respond_to?(:nobrainer_cast_db_to_model) value.class.nobrainer_cast_db_to_model(method, value) else value end end end |
.nobrainer_cast_model_to_db(values) ⇒ Object
delegate cast to each array element
17 18 19 20 21 22 23 24 25 |
# File 'lib/no_brainer/document/types/array.rb', line 17 def self.nobrainer_cast_model_to_db(values) ::Array.wrap(values).map do |value| if value.class.respond_to?(:nobrainer_cast_model_to_db) value.class.nobrainer_cast_model_to_db(value) else value end end end |
.nobrainer_cast_user_to_model(values) ⇒ Object
delegate cast to each array element
6 7 8 9 10 11 12 13 14 |
# File 'lib/no_brainer/document/types/array.rb', line 6 def self.nobrainer_cast_user_to_model(values) ::Array.wrap(values).map do |value| if value.class.respond_to?(:nobrainer_cast_user_to_model) value.class.nobrainer_cast_user_to_model(value) else value end end end |
.of(object_type = nil, **options) ⇒ Object
convenience method to create a TypedArray
39 40 41 |
# File 'lib/no_brainer/document/types/array.rb', line 39 def self.of(object_type = nil, **) NoBrainer::TypedArray.of(object_type, **) end |