Sha256: 4e96f6307f956343c0150d92f61b209df67d32dd493b29f35f83ff444741b108

Contents?: true

Size: 536 Bytes

Versions: 1

Compression:

Stored size: 536 Bytes

Contents

module LastpassCLI
  class Item
    def self.attributes
      %w[id name folder username modified_at password notes number url]
    end

    attr_accessor *attributes

    def initialize(attrs)
      attrs.each do |k, v|
        set(k.to_s, v)
      end
    end

    def set(attribute, value)
      if self.class.attributes.include?(attribute)
        send("#{attribute}=", value)
      end
    end

    def to_h
      self.class.attributes.each_with_object({}) do |attr, hsh|
        hsh[attr] = send(attr)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lastpass-cli-0.1.1 lib/lastpass-cli/item.rb