Class: EndpointSecurity::NativeView
- Inherits:
-
Object
- Object
- EndpointSecurity::NativeView
- Defined in:
- lib/endpoint_security/object_model.rb
Overview
Base for lazy views backed by a native message.
Instance Method Summary collapse
-
#method_missing(name) ⇒ Object
private
Resolves generated native fields lazily.
- #respond_to_missing?(name, include_private = false) ⇒ Boolean
- #to_h ⇒ Hash
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Resolves generated native fields lazily.
92 93 94 95 96 97 98 99 100 |
# File 'lib/endpoint_security/object_model.rb', line 92 def method_missing(name, ...) field = name.to_s.delete_suffix("?") predicate = name.to_s.end_with?("?") field = "is_#{field}" if predicate && __field_names.include?(:"is_#{field}") return super unless __field_names.include?(field.to_sym) value = __read_field(field) value.is_a?(Array) ? FieldArray.new { value } : value end |
Instance Method Details
#respond_to_missing?(name, include_private = false) ⇒ Boolean
102 103 104 105 |
# File 'lib/endpoint_security/object_model.rb', line 102 def respond_to_missing?(name, include_private = false) field = name.to_s.delete_suffix("?") __field_names.include?(field.to_sym) || __field_names.include?(:"is_#{field}") || super end |
#to_h ⇒ Hash
86 87 88 |
# File 'lib/endpoint_security/object_model.rb', line 86 def to_h __field_names.to_h { |name| [name, deep_copy(public_send(name))] } end |