Class: StructuredDataToSql::ProgressEvent

Inherits:
Object
  • Object
show all
Includes:
ImmutableValue
Defined in:
lib/structured_data_to_sql/conversion_result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, attributes = {}) ⇒ ProgressEvent

Returns a new instance of ProgressEvent.



68
69
70
71
72
# File 'lib/structured_data_to_sql/conversion_result.rb', line 68

def initialize(type, attributes = {})
  @type = type.to_sym
  @attributes = deep_freeze(attributes.transform_keys(&:to_sym))
  freeze
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



84
85
86
87
88
# File 'lib/structured_data_to_sql/conversion_result.rb', line 84

def method_missing(name, *args)
  return @attributes[name] if args.empty? && @attributes.key?(name)

  super
end

Instance Attribute Details

#typeObject (readonly) Also known as: event

Returns the value of attribute type.



66
67
68
# File 'lib/structured_data_to_sql/conversion_result.rb', line 66

def type
  @type
end

Instance Method Details

#[](key) ⇒ Object



76
77
78
# File 'lib/structured_data_to_sql/conversion_result.rb', line 76

def [](key)
  key.to_sym == :event ? type : @attributes[key.to_sym]
end

#respond_to_missing?(name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


90
91
92
# File 'lib/structured_data_to_sql/conversion_result.rb', line 90

def respond_to_missing?(name, include_private = false)
  @attributes.key?(name) || super
end

#to_hObject



80
81
82
# File 'lib/structured_data_to_sql/conversion_result.rb', line 80

def to_h
  @attributes.merge(event: type)
end