lib/misp/attribute.rb in misp-0.1.1 vs lib/misp/attribute.rb in misp-0.1.2
- old
+ new
@@ -37,11 +37,11 @@
attr_accessor :shadow_attributes
# @return [Array<MISP::Tag>]
attr_accessor :tags
def initialize(**attributes)
- attributes = normalize_attributes(attributes)
+ attributes = normalize_attributes(**attributes)
@id = attributes.dig(:id)
@type = attributes.dig(:type)
@category = attributes.dig(:category)
@to_ids = attributes.dig(:to_ids)
@@ -110,11 +110,11 @@
# Create an attribute
#
# @return [MISP::Attribute]
#
def create(event_id)
- _post("/attributes/add/#{event_id}", wrap(to_h)) { |attribute| Attribute.new attribute }
+ _post("/attributes/add/#{event_id}", wrap(to_h)) { |attribute| Attribute.new(**attribute) }
end
#
# Update an attribute
#
@@ -123,11 +123,11 @@
# @return [MISP::Attribute]
#
def update(**attrs)
payload = to_h.merge(attrs)
payload[:timestamp] = nil
- _post("/attributes/edit/#{id}", wrap(payload)) { |json| Attribute.new json.dig(:response, :Attribute) }
+ _post("/attributes/edit/#{id}", wrap(payload)) { |json| Attribute.new(**json.dig(:response, :Attribute)) }
end
#
# Search for attributes
#
@@ -142,11 +142,11 @@
page: "0"
}
_post("/attributes/restSearch", base.merge(params)) do |json|
attributes = json.dig(:response, :Attribute) || []
- attributes.map { |attribute| Attribute.new attribute }
+ attributes.map { |attribute| Attribute.new(**attribute) }
end
end
#
# Add a tag to an attribute
@@ -156,11 +156,11 @@
# @return [MISP::Tag]
#
def add_tag(tag)
tag = Tag.new(tag) unless tag.is_a?(MISP::Tag)
payload = { uuid: uuid, tag: tag.name }
- _post("/tags/attachTagToObject", payload) { |json| Tag.new json }
+ _post("/tags/attachTagToObject", payload) { |json| Tag.new(**json) }
end
#
# Remove a tag from an attribute
#
@@ -182,14 +182,14 @@
def delete(id)
new(id: id).delete
end
def create(event_id, **attributes)
- new(attributes).create(event_id)
+ new(**attributes).create(event_id)
end
def search(**params)
- new.search params
+ new.search(**params)
end
end
end
end