Class: SBF::Client::NotImplementedObject

Inherits:
BaseEntity
  • Object
show all
Defined in:
lib/stbaldricks/entities/lib/not_implemented_object.rb

Constant Summary

Constants inherited from BaseEntity

BaseEntity::ELSE

Instance Attribute Summary collapse

Attributes inherited from BaseEntity

#errors

Instance Method Summary collapse

Methods inherited from BaseEntity

allow_instantiation?, attr_accessor, attr_reader, attr_writer, collection_attributes, defined_attributes, #destroyed?, #dirty_data, entity_attr_accessor, entity_attr_reader, entity_attr_writer, entity_attributes, entity_collection_attr_accessor, entity_collection_attr_reader, entity_collection_attr_writer, #error, inherited, #keys_hash, #model_name, multitype_attr_accessor, multitype_attr_reader, multitype_attr_writer, multitype_collection_attr_accessor, multitype_collection_attr_reader, multitype_collection_attr_writer, #not_provided_attributes, optional_attributes, #persisted?, #reload!, #reload_recursive, #rollback!, #to_json, #to_partial

Methods included from EntityResponseConcern

#add_errors, #data, #error?, #errors?, #errors_http_code=, #http_code, #success?

Constructor Details

#initialize(attributes = {}) ⇒ NotImplementedObject

Returns a new instance of NotImplementedObject.



9
10
11
12
13
14
15
16
17
# File 'lib/stbaldricks/entities/lib/not_implemented_object.rb', line 9

def initialize(attributes = {})
  @props = {}.tap do |hsh|
    attributes.each do |k, v|
      hsh[k.to_sym] = v
    end
  end

  super
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name) ⇒ Object

rubocop:disable Style/MissingRespondToMissing



20
21
22
23
24
# File 'lib/stbaldricks/entities/lib/not_implemented_object.rb', line 20

def method_missing(name)
  return @props[name.to_sym] if @props.key?(name.to_sym)

  super.method_missing(name)
end

Instance Attribute Details

#propsObject

Returns the value of attribute props.



7
8
9
# File 'lib/stbaldricks/entities/lib/not_implemented_object.rb', line 7

def props
  @props
end

Instance Method Details

#to_hashObject

rubocop:enable Style/MissingRespondToMissing



27
28
29
30
31
32
# File 'lib/stbaldricks/entities/lib/not_implemented_object.rb', line 27

def to_hash
  {}.tap do |hsh|
    props.each { |k, v| hsh[k] = v }
    self.class.defined_attributes.each { |name| hsh[name] = send(name.to_sym) unless hsh.key?(name.to_sym) || name.to_sym == :props }
  end
end