Class: StructuredDataToSql::ProgressEvent
- Inherits:
-
Object
- Object
- StructuredDataToSql::ProgressEvent
show all
- Includes:
- ImmutableValue
- Defined in:
- lib/structured_data_to_sql/conversion_result.rb
Instance Attribute Summary collapse
-
#type ⇒ Object
(also: #event)
readonly
Returns the value of attribute type.
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
#type ⇒ Object
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
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_h ⇒ Object
80
81
82
|
# File 'lib/structured_data_to_sql/conversion_result.rb', line 80
def to_h
@attributes.merge(event: type)
end
|