Class: JSONAPIonify::Structure::Objects::TopLevel
- Defined in:
- lib/jsonapionify/structure/objects/top_level.rb
Instance Attribute Summary collapse
-
#origin ⇒ Object
readonly
Returns the value of attribute origin.
Attributes inherited from Base
#errors, #object, #parent, #warnings
Instance Method Summary collapse
Methods inherited from Base
#==, #===, #as_json, #compile!, #copy, define_order, from_hash, from_json, #initialize, #inspect, #pretty_json, #signature, #to_h, #to_json, #validate
Methods included from Helpers::ObjectDefaults
Methods included from Helpers::Validations
#allowed_type_map, #permitted_key?, #permitted_keys, #permitted_type_for?, #permitted_types_for, #required_key?, #required_keys
Methods included from Helpers::ObjectSetters
Methods included from Helpers::InheritsOrigin
Methods included from Callbacks
Constructor Details
This class inherits a constructor from JSONAPIonify::Structure::Objects::Base
Instance Attribute Details
#origin ⇒ Object (readonly)
Returns the value of attribute origin.
9 10 11 |
# File 'lib/jsonapionify/structure/objects/top_level.rb', line 9 def origin @origin end |
Instance Method Details
#as(origin) ⇒ Object
96 97 98 99 100 |
# File 'lib/jsonapionify/structure/objects/top_level.rb', line 96 def as(origin) copy.tap do |obj| obj.instance_variable_set :@origin, origin end end |
#compile(**opts) ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/jsonapionify/structure/objects/top_level.rb', line 80 def compile(**opts) compiled = super(**opts) compiled_errors = compiled['errors'] || [] all_errors = compiled_errors | errors.as_collection.compile if all_errors.present? self.class.new( errors: all_errors, meta: { invalid_object: to_h } ).compile else compiled end end |