Class: ATSD::PropertiesService
- Inherits:
-
BaseService
- Object
- BaseService
- ATSD::PropertiesService
- Defined in:
- lib/atsd/services/properties_service.rb
Instance Method Summary collapse
-
#delete(properties) ⇒ self
Delete properties.
-
#insert(properties) ⇒ self
Insert properties.
-
#query(entity, type, options = {}) ⇒ PropertiesQuery
Create query builder for properties.
-
#type_query(entity) ⇒ self
Returns an array of property types for the entity.
-
#url_query(entity, type) ⇒ self
Retrieve property records for the specified entity and type.
Methods inherited from BaseService
Constructor Details
This class inherits a constructor from ATSD::BaseService
Instance Method Details
#delete(properties) ⇒ self
Delete properties.
60 61 62 63 64 65 66 67 68 |
# File 'lib/atsd/services/properties_service.rb', line 60 def delete(properties) properties = Utils.ensure_array(properties).map do |s| s = s.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo} s = Property.new(s) if s.is_a? Hash s.to_request_hash.select { |k, v| [:entity, :type, :key].include? k } end @client.properties_delete(properties) self end |
#insert(properties) ⇒ self
Insert properties.
27 28 29 30 31 32 33 34 |
# File 'lib/atsd/services/properties_service.rb', line 27 def insert(properties) properties = Utils.ensure_array(properties).map do |s| s = Property.new(s) if s.is_a? Hash s.to_request_hash end @client.properties_insert properties self end |
#query(entity, type, options = {}) ⇒ PropertiesQuery
Create query builder for properties.
14 15 16 17 18 19 20 |
# File 'lib/atsd/services/properties_service.rb', line 14 def query(entity, type, = {}) query = PropertiesQuery.new @client entity = entity.name if entity.is_a? Entity .merge! entity: entity, type: type .each { |option, value| query[option] = value } query end |
#type_query(entity) ⇒ self
Returns an array of property types for the entity.
41 42 43 |
# File 'lib/atsd/services/properties_service.rb', line 41 def type_query(entity) @client.properties_for_entity(entity) end |
#url_query(entity, type) ⇒ self
Retrieve property records for the specified entity and type.
51 52 53 |
# File 'lib/atsd/services/properties_service.rb', line 51 def url_query(entity, type) @client.properties_for_entity_and_type(entity,type) end |