Class: Replicate::Record::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/replicate/record/base.rb

Direct Known Subclasses

Model, ModelVersion, Prediction, Training, Upload

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, params) ⇒ Base

Returns a new instance of Base.



9
10
11
12
# File 'lib/replicate/record/base.rb', line 9

def initialize(client, params)
  @client = client
  @data = params
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



14
15
16
17
18
19
20
# File 'lib/replicate/record/base.rb', line 14

def method_missing(method_name, *args, &block)
  if data.key? method_name.to_s
    data[method_name.to_s]
  else
    super
  end
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



7
8
9
# File 'lib/replicate/record/base.rb', line 7

def client
  @client
end

#dataObject

Returns the value of attribute data.



6
7
8
# File 'lib/replicate/record/base.rb', line 6

def data
  @data
end

Instance Method Details

#inspectObject



22
23
24
25
26
# File 'lib/replicate/record/base.rb', line 22

def inspect
  string = "#<#{self.class.name}:#{object_id} "
  fields = data.map { |attr, value| "#{attr}: #{value.inspect}" }
  string << fields.join(", ") << ">"
end