Sha256: de97d24b3bb869c0d2391c4b603f5e5c7c260b9a1e6da6be2226d68349243c0a

Contents?: true

Size: 1.23 KB

Versions: 3

Compression:

Stored size: 1.23 KB

Contents

module OpConnect
  class Item
    autoload :Field, "op_connect/item/field"
    autoload :File, "op_connect/item/file"
    autoload :GeneratorRecipe, "op_connect/item/generator_recipe"
    autoload :Section, "op_connect/item/section"
    autoload :URL, "op_connect/item/url"

    attr_reader :id, :title, :vault, :category, :urls, :is_favorite, :tags, :version, :state, :sections, :fields, :files, :created_at, :updated_at, :last_edited_by

    alias_method :favorite?, :is_favorite

    def initialize(options = {})
      @id = options["id"]
      @title = options["title"]
      @vault = Object.new(options["vault"])
      @category = options["category"]
      @urls = options["urls"]&.collect! { |url| URL.new(url) }
      @is_favorite = options["favorite"] || false
      @tags = options["tags"]
      @version = options["version"]
      @state = options["state"]
      @sections = options["sections"]&.collect! { |section| Section.new(section) } || []
      @fields = options["fields"]&.collect! { |field| Field.new(field) } || []
      @files = options["files"]&.collect! { |file| File.new(file) } || []
      @created_at = options["createdAt"]
      @updated_at = options["updatedAt"]
      @last_edited_by = options["lastEditedBy"]
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
op_connect-0.1.3 lib/op_connect/item.rb
op_connect-0.1.2 lib/op_connect/item.rb
op_connect-0.1.1 lib/op_connect/item.rb