0

so I have a Class

=> #9} @signature_metrics={"Alert [1:485:4]"=>9} @src_ips={"93.21.29.12"=>9,"0.0.0.0",3} @dst_ips={"10.15.255.135"=>9} @created_at=Sat, 04 Mar 2017 17:31:59 UTC +00:00 @updated_at=Sat, 04 Mar 2017 18:02:02 UTC +00:00>

=> [#<DataMapper::Property::Serial @model=Cache @name=:id>, #<DataMapper::Property::Integer @model=Cache @name=:sid>, #<DataMapper::Property::Integer @model=Cache @name=:cid>, #<DataMapper::Property::ZonedTime @model=Cache @name=:ran_at>, #<DataMapper::Property::Integer @model=Cache @name=:event_count>, #<DataMapper::Property::Integer @model=Cache @name=:tcp_count>, #<DataMapper::Property::Integer @model=Cache @name=:udp_count>, #<DataMapper::Property::Integer @model=Cache @name=:icmp_count>, #<DataMapper::Property::Object @model=Cache @name=:severity_metrics>, #<DataMapper::Property::Object @model=Cache @name=:signature_metrics>, #<DataMapper::Property::Object @model=Cache @name=:src_ips>, #<DataMapper::Property::Object @model=Cache @name=:dst_ips>, #<DataMapper::Property::ZonedTime @model=Cache @name=:created_at>, #<DataMapper::Property::ZonedTime @model=Cache @name=:updated_at>]

from there I wanted to query @cache.all(src_ids => '93.21.29.12') which does not work.

How could I query to match all lines that contain in the "src_ips" fields as a key "0.0.0.0"?

Mark Ruth
  • 23
  • 6

1 Answers1

1

You can use where:

records = Cache.where(src_ips: "0.0.0.0")
Shannon
  • 2,988
  • 10
  • 21