Class: LWS::Resource::Collection

Inherits:
Generic::Model show all
Defined in:
lib/lws/apps/resource.rb

Overview

The collection class

A collection has a specific kind and contains a single or set of items. For some collection kinds, there is specific metadata (see #metadata) available.

Defined Under Namespace

Classes: Item, Metadata, VimeoMetadata, WeatherLocationMetadata, YouTubeMetadata

Instance Attribute Summary collapse

Attributes inherited from Generic::Model

#created_at, #id, #updated_at, #url, #url_html

Instance Method Summary collapse

Methods inherited from Generic::Model

#deep_dup, #dig, #reload, #rollback, #save

Instance Attribute Details

#accountLWS::Auth::Account

Returns the account of the user that created the collection.

Returns:



54
# File 'lib/lws/apps/resource.rb', line 54

belongs_to :account, class_name: "LWS::Auth::Account"

#account_idInteger

Returns the ID of the account of the user that created the collection.

Returns:

  • (Integer)

    the ID of the account of the user that created the collection



59
# File 'lib/lws/apps/resource.rb', line 59

attribute :account_id

#companyLWS::Auth::Company

Returns the company the collection belongs to.

Returns:



63
# File 'lib/lws/apps/resource.rb', line 63

belongs_to :company, class_name: "LWS::Auth::Company"

#company_idInteger

Returns the ID of the company the collection belongs to.

Returns:

  • (Integer)

    the ID of the company the collection belongs to



67
# File 'lib/lws/apps/resource.rb', line 67

attribute :company_id

#deleted_atString?

Returns the timestamp of when the collection was deleted.

Returns:

  • (String, nil)

    the timestamp of when the collection was deleted



71
# File 'lib/lws/apps/resource.rb', line 71

attribute :deleted_at

#descriptionString

Returns the description of the collection.

Returns:

  • (String)

    the description of the collection



75
# File 'lib/lws/apps/resource.rb', line 75

attribute :description

#emailString?

Returns the email address used for email imports.

Returns:

  • (String, nil)

    the email address used for email imports



79
# File 'lib/lws/apps/resource.rb', line 79

attribute :email

#folderFolder

Returns the folder that the collection is filed in.

Returns:

  • (Folder)

    the folder that the collection is filed in



83
# File 'lib/lws/apps/resource.rb', line 83

belongs_to :folder

#folder_idInteger

Returns the ID of the folder that the collection is filed in.

Returns:

  • (Integer)

    the ID of the folder that the collection is filed in



88
# File 'lib/lws/apps/resource.rb', line 88

attribute :folder_id

#item_idsArray<Integer>

Returns the ID of the items that are part of the collection.

Returns:

  • (Array<Integer>)

    the ID of the items that are part of the collection



93
# File 'lib/lws/apps/resource.rb', line 93

attribute :item_ids

#itemsArray<Collection::Item>

Returns the items that are part of the collection.

Returns:



98
# File 'lib/lws/apps/resource.rb', line 98

has_many :items, class_name: "LWS::Resource::Collection::Item"

#kind"image", ...

Note:

This library only supports a subset of the available collection/item kinds.

Returns the name of the class/kind of the

collection.

Returns:

  • ("image", "other", "pdf", "powerpoint", "video", "vimeo", "weather_location", "youtube")

    the name of the class/kind of the

    collection
    


107
# File 'lib/lws/apps/resource.rb', line 107

attribute :kind

#nameString

Returns the name of the collection.

Returns:

  • (String)

    the name of the collection



111
# File 'lib/lws/apps/resource.rb', line 111

attribute :name

#preview_urlString

Returns the URL of a preview of the collection.

Returns:

  • (String)

    the URL of a preview of the collection



115
# File 'lib/lws/apps/resource.rb', line 115

attribute :preview_url

#processingBoolean

Returns whether the collection is being processed (i.e. it is not ready for use).

Returns:

  • (Boolean)

    whether the collection is being processed (i.e. it is not ready for use)



120
# File 'lib/lws/apps/resource.rb', line 120

attribute :processing

#uuidString

Returns the UUID used for unique file name generation.

Returns:

  • (String)

    the UUID used for unique file name generation



124
# File 'lib/lws/apps/resource.rb', line 124

attribute :uuid

Instance Method Details

#metadataCollection::Metadata

Returns the metadata of the collection specific to its kind.

Returns:



129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/lws/apps/resource.rb', line 129

def 
  case kind
  # when "feed"
  #   attrs =
  #     attributes["metadata"]
  #       .slice("feed_url", "refresh_interval")
  #       .symbolize_keys
  #   FeedMetadata.new(attrs)
  when "vimeo"
    attrs = attributes["metadata"]
      .slice("video_url")
      .symbolize_keys
    VimeoMetadata.new(attrs)
  when "weather_location"
    attrs =
      attributes["metadata"]
        .slice("city", "country", "description", "feed_url",
          "forecast_interval", "kind", "lat", "link", "long", "name",
          "refresh_interval", "regio", "title", "token")
        .symbolize_keys
    WeatherLocationMetadata.new(attrs)
  when "youtube"
    attrs = attributes["metadata"]
      .slice("video_url")
      .symbolize_keys
    YouTubeMetadata.new(attrs)
  else
    Metadata.new
  end
end