Class: Necropsy::UnknownScope

Inherits:
Data
  • Object
show all
Defined in:
lib/necropsy/models.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scope_kind:, scope_value:, match:) ⇒ UnknownScope

Returns a new instance of UnknownScope.

Raises:

  • (ArgumentError)


104
105
106
107
108
109
110
111
112
# File 'lib/necropsy/models.rb', line 104

def initialize(scope_kind:, scope_value:, match:)
  scope_kind = scope_kind.to_sym if scope_kind.respond_to?(:to_sym)
  match = match.to_sym if match.respond_to?(:to_sym)
  raise ArgumentError, "invalid unknown scope kind: #{scope_kind.inspect}" unless UNKNOWN_SCOPE_KINDS.include?(scope_kind)
  raise ArgumentError, "invalid unknown scope match: #{match.inspect}" unless UNKNOWN_SCOPE_MATCHES.include?(match)

  scope_value = ModelNormalization.scope_value(scope_value)
  super
end

Instance Attribute Details

#matchObject (readonly)

Returns the value of attribute match

Returns:

  • (Object)

    the current value of match



103
104
105
# File 'lib/necropsy/models.rb', line 103

def match
  @match
end

#scope_kindObject (readonly)

Returns the value of attribute scope_kind

Returns:

  • (Object)

    the current value of scope_kind



103
104
105
# File 'lib/necropsy/models.rb', line 103

def scope_kind
  @scope_kind
end

#scope_valueObject (readonly)

Returns the value of attribute scope_value

Returns:

  • (Object)

    the current value of scope_value



103
104
105
# File 'lib/necropsy/models.rb', line 103

def scope_value
  @scope_value
end

Class Method Details

.from_h(attributes) ⇒ Object



114
115
116
117
118
119
120
121
# File 'lib/necropsy/models.rb', line 114

def self.from_h(attributes)
  data = ModelNormalization.attributes(attributes, name)
  new(
    scope_kind: data.fetch('scope_kind'),
    scope_value: data.fetch('scope_value'),
    match: data.fetch('match')
  )
end

Instance Method Details

#to_hObject



123
124
125
126
127
128
129
# File 'lib/necropsy/models.rb', line 123

def to_h
  {
    'scope_kind' => scope_kind.to_s,
    'scope_value' => scope_value,
    'match' => match.to_s
  }
end