Class: OdataDuty::CreateComplexTypeHashWrapper
- Inherits:
-
Object
- Object
- OdataDuty::CreateComplexTypeHashWrapper
- Defined in:
- lib/odata_duty/create_complex_type_hash_wrapper.rb
Constant Summary collapse
- SETTABLE_BY_OPERATION =
{ create: :settable_on_create?, update: :settable_on_update? }.freeze
Instance Method Summary collapse
-
#initialize(hash, complex_type, operation:, context:) ⇒ CreateComplexTypeHashWrapper
constructor
A new instance of CreateComplexTypeHashWrapper.
- #method_missing(method_name, *args) ⇒ Object
- #respond_to_missing?(method_name, _include_private) ⇒ Boolean
Constructor Details
#initialize(hash, complex_type, operation:, context:) ⇒ CreateComplexTypeHashWrapper
Returns a new instance of CreateComplexTypeHashWrapper.
5 6 7 8 9 10 |
# File 'lib/odata_duty/create_complex_type_hash_wrapper.rb', line 5 def initialize(hash, complex_type, operation:, context:) @hash = hash @complex_type = complex_type @operation = operation @context = context end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/odata_duty/create_complex_type_hash_wrapper.rb', line 12 def method_missing(method_name, *args) matching_prop = @complex_type.properties.find { |p| p.name == method_name } unless matching_prop && args.empty? raise NoSuchPropertyError, "No such property '#{method_name}'" end __load(matching_prop, method_name, @hash[method_name.to_s]) end |
Instance Method Details
#respond_to_missing?(method_name, _include_private) ⇒ Boolean
21 22 23 |
# File 'lib/odata_duty/create_complex_type_hash_wrapper.rb', line 21 def respond_to_missing?(method_name, _include_private) @complex_type.properties.any? { |p| p.name == method_name } end |