Class: Helm::Queries::Server
- Inherits:
-
Helm::Query
- Object
- Helm::Query
- Helm::Queries::Server
- Defined in:
- lib/helm/queries/server.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
-
#id_from_platform ⇒ Object
Returns the value of attribute id_from_platform.
-
#name ⇒ Object
Returns the value of attribute name.
-
#platform ⇒ Object
Returns the value of attribute platform.
-
#role ⇒ Object
Returns the value of attribute role.
-
#server_id ⇒ Object
Returns the value of attribute server_id.
Attributes inherited from Helm::Query
Instance Method Summary collapse
- #constraint ⇒ Object
- #constraint_attrs ⇒ Object
- #constraint_hash ⇒ Object
- #inspect ⇒ Object
- #result_class ⇒ Object
- #to_s ⇒ Object
Methods inherited from Helm::Query
Constructor Details
This class inherits a constructor from Helm::Query
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
7 8 9 |
# File 'lib/helm/queries/server.rb', line 7 def client @client end |
#id_from_platform ⇒ Object
Returns the value of attribute id_from_platform.
7 8 9 |
# File 'lib/helm/queries/server.rb', line 7 def id_from_platform @id_from_platform end |
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'lib/helm/queries/server.rb', line 7 def name @name end |
#platform ⇒ Object
Returns the value of attribute platform.
7 8 9 |
# File 'lib/helm/queries/server.rb', line 7 def platform @platform end |
#role ⇒ Object
Returns the value of attribute role.
7 8 9 |
# File 'lib/helm/queries/server.rb', line 7 def role @role end |
#server_id ⇒ Object
Returns the value of attribute server_id.
7 8 9 |
# File 'lib/helm/queries/server.rb', line 7 def server_id @server_id end |
Instance Method Details
#constraint ⇒ Object
29 30 31 |
# File 'lib/helm/queries/server.rb', line 29 def constraint @constraint ||= @db[:servers].where(constraint_hash) end |
#constraint_attrs ⇒ Object
18 19 20 |
# File 'lib/helm/queries/server.rb', line 18 def constraint_attrs [:server_id, :client, :name, :role, :platform, :id_from_plaform] end |
#constraint_hash ⇒ Object
22 23 24 25 26 27 |
# File 'lib/helm/queries/server.rb', line 22 def constraint_hash @constraint_hash ||= constraint_attrs.each_with_object({}) do |attr, hash| val = instance_variable_get("@#{attr}") hash[attr] = val unless val.nil? end end |
#inspect ⇒ Object
14 15 16 |
# File 'lib/helm/queries/server.rb', line 14 def inspect "<#{self.class.name}:#{"%0x" % object_id} #{constraint.select_sql rescue "<?sql?>"}>" end |
#result_class ⇒ Object
33 34 35 |
# File 'lib/helm/queries/server.rb', line 33 def result_class Records::Server end |
#to_s ⇒ Object
9 10 11 12 |
# File 'lib/helm/queries/server.rb', line 9 def to_s nil_attrs = constraint_attrs.reject{|attr| constraint_hash.has_key?(attr) } "Servers query: #{constraint_hash.inspect} (not set: #{nil_attrs.inspect})" end |