Class: TimelyApp::Record

Inherits:
Object
  • Object
show all
Defined in:
lib/timely-app/record.rb,
sig/timely-app/record.rbs

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Record

Returns a new instance of Record.

Parameters:

  • (defaults to: {})


3
4
5
# File 'lib/timely-app/record.rb', line 3

def initialize(attributes = {})
  @attributes = attributes
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) {|arg0| ... } ⇒ Object

Parameters:

Yields:

Yield Parameters:

  • arg0 (Object)

Yield Returns:

  • (Object)

Returns:



15
16
17
18
19
20
21
# File 'lib/timely-app/record.rb', line 15

def method_missing(name, *args, &block)
  if @attributes.has_key?(name) && args.empty? && block.nil?
    @attributes[name]
  else
    super
  end
end

Instance Method Details

#[](name) ⇒ Object

Parameters:

Returns:



7
8
9
# File 'lib/timely-app/record.rb', line 7

def [](name)
  @attributes[name]
end

#[]=(name, value) ⇒ Object

Parameters:

Returns:



11
12
13
# File 'lib/timely-app/record.rb', line 11

def []=(name, value)
  @attributes[name] = value
end

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

Parameters:

Returns:



23
24
25
# File 'lib/timely-app/record.rb', line 23

def respond_to_missing?(name, _include_private = false)
  @attributes.has_key?(name)
end

#to_hHash[Symbol, untyped]

Returns:



27
28
29
# File 'lib/timely-app/record.rb', line 27

def to_h
  @attributes
end