Module: InfluxORM::Attributes::ClassMethods
- Defined in:
- lib/influx_orm/attributes.rb
Instance Method Summary collapse
- #attrs_to_point(hash) ⇒ Object
- #influx_attrs ⇒ Object
- #influx_tag(name) ⇒ Object
- #influx_value(name, type = :int) ⇒ Object
Instance Method Details
#attrs_to_point(hash) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/influx_orm/attributes.rb', line 22 def attrs_to_point(hash) point = {tags: {}, values: {}} hash.each do |k, v| next if k == :timestamp if k.to_sym == :time point[:timestamp] = (v) next end col_type, data_type = influx_attrs[k.to_sym] raise InfluxORM::Error.new("Invalid col_type '#{col_type}' of '#{k}'") unless col_type point[col_type][k] = convert_val(data_type, v) end point[:timestamp] ||= (Time.now) point end |
#influx_attrs ⇒ Object
9 10 11 |
# File 'lib/influx_orm/attributes.rb', line 9 def influx_attrs @influx_attrs ||= {} end |
#influx_tag(name) ⇒ Object
13 14 15 |
# File 'lib/influx_orm/attributes.rb', line 13 def influx_tag(name) influx_attrs[name.to_sym] = [:tags, :string] end |
#influx_value(name, type = :int) ⇒ Object
17 18 19 20 |
# File 'lib/influx_orm/attributes.rb', line 17 def influx_value(name, type = :int) raise InfluxORM::Error.new("Invalid type '#{type}'") unless ATTR_TYPES.include?(type) influx_attrs[name.to_sym] = [:values, type] end |