Class: Keepassx::Entry
Instance Attribute Summary collapse
-
#group ⇒ Object
Returns the value of attribute group.
Attributes inherited from Fieldable
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(payload) ⇒ Entry
constructor
A new instance of Entry.
Methods inherited from Fieldable
create_fieldable_methods, #encode, fields, #inspect, #length, set_field_descriptor, #to_hash
Constructor Details
#initialize(payload) ⇒ Entry
Returns a new instance of Entry.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/keepassx/entry.rb', line 38 def initialize(payload) super do # Do some validation raise ArgumentError, "'name' is required (type: string)" unless valid_string?(payload[:name]) raise ArgumentError, "'group_id' is required (type: integer)" unless payload[:group] || valid_integer?(payload[:group_id]) # First set @group and @group_id. # Remove key from payload to not interfere with KeePassX fields format self.group = payload.delete(:group) # Add group_id key to respect KeePassX fields format payload[:group_id] = group.id # Build list of fields @fields = build_payload(payload) end end |
Instance Attribute Details
#group ⇒ Object
Returns the value of attribute group.
36 37 38 |
# File 'lib/keepassx/entry.rb', line 36 def group @group end |