Class: DaggerRuby::DaggerObject

Inherits:
Object
  • Object
show all
Defined in:
lib/dagger_ruby/dagger_object.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(query_builder = nil, client = nil) ⇒ DaggerObject

Returns a new instance of DaggerObject.



10
11
12
13
# File 'lib/dagger_ruby/dagger_object.rb', line 10

def initialize(query_builder = nil, client = nil)
  @query_builder = query_builder || QueryBuilder.new(self.class.root_field_name)
  @client = client
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



8
9
10
# File 'lib/dagger_ruby/dagger_object.rb', line 8

def client
  @client
end

#query_builderObject (readonly)

Returns the value of attribute query_builder.



8
9
10
# File 'lib/dagger_ruby/dagger_object.rb', line 8

def query_builder
  @query_builder
end

Class Method Details

.from_id(id, client) ⇒ Object



82
83
84
85
86
# File 'lib/dagger_ruby/dagger_object.rb', line 82

def from_id(id, client)
  query = QueryBuilder.new(root_field_name)
  query.load_from_id(id)
  new(query, client)
end

.root_field_nameObject



88
89
90
# File 'lib/dagger_ruby/dagger_object.rb', line 88

def root_field_name
  name.split("::").last.downcase
end

Instance Method Details

#chain_operation(field, args = {}) ⇒ Object



15
16
17
18
# File 'lib/dagger_ruby/dagger_object.rb', line 15

def chain_operation(field, args = {})
  new_query = @query_builder.chain_operation(field, args)
  self.class.new(new_query, @client)
end

#idObject



20
21
22
# File 'lib/dagger_ruby/dagger_object.rb', line 20

def id
  @id ||= get_scalar("id")
end