Class: Purview::Structs::Base

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/purview/structs/base.rb

Direct Known Subclasses

Result, Row, TableMetadata, Window

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object

Raises:

  • (NoMethodError)


14
15
16
17
18
# File 'lib/purview/structs/base.rb', line 14

def method_missing(method, *args, &block)
  method = method.to_sym unless method.is_a?(Symbol)
  raise NoMethodError if args.empty? && !respond_to?(method)
  super
end

Instance Method Details

#[](key) ⇒ Object

Raises:

  • (NoMethodError)


4
5
6
7
8
# File 'lib/purview/structs/base.rb', line 4

def [](key)
  key = key.to_sym unless key.is_a?(Symbol)
  raise NoMethodError unless respond_to?(key)
  send(key)
end

#[]=(key, value) ⇒ Object



10
11
12
# File 'lib/purview/structs/base.rb', line 10

def []=(key, value)
  send("#{key}=", value)
end