Class: Smartfm::List
- Includes:
- ActsAsLikable, PublicContent
- Defined in:
- lib/smartfm/models/list.rb
Defined Under Namespace
Classes: Application
Constant Summary collapse
- ATTRIBUTES =
[:id, :title, :description, :icon, :square_icon, :item_count, :user_count, :iknow, :dictation, :brainspeed, :language, :translation_language, :item_type, :transcript, :embed, :tags, :media_entry, :attribution_license_id, :items, :sentences, :user]
- READONLY_ATTRIBUTES =
[:id, :icon, :item_count, :user_count, :iknow, :dictation, :brainspeed, :user]
Class Method Summary collapse
Instance Method Summary collapse
- #add_item(auth, item) ⇒ Object
- #delete_item(auth, item) ⇒ Object
-
#initialize(params = {}) ⇒ List
constructor
A new instance of List.
- #items(params = {}) ⇒ Object
- #rest_client ⇒ Object
- #sentences(params = {}) ⇒ Object
Methods included from ActsAsLikable
Methods included from PublicContent
Methods inherited from Base
Constructor Details
#initialize(params = {}) ⇒ List
Returns a new instance of List.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/smartfm/models/list.rb', line 37 def initialize(params = {}) @id = (params[:id].to_i rescue nil) @title = params[:title] @description = params[:description] @icon = params[:icon] @square_icon = params[:square_icon] @item_count = (params[:item_count].to_i rescue nil) @user_count = (params[:user_count].to_i rescue nil) @language = params[:language] @translation_language = params[:translation_language] if @id and @translation_language common_settings = {:list_id => @id, :lang => @translation_language} @iknow = Application.new(common_settings.merge(:iknow => params[:iknow])) @dictation = Application.new(common_settings.merge(:dictation => params[:dictation])) @brainspeed = Application.new(common_settings.merge(:brainspeed => params[:brainspeed])) end @item_type = params[:item_type] # for list creation @transcript = params[:transcript] # for list creation @embed = params[:embed] # for list creation @tags = params[:tags] # for list creation @media_entry = params[:media_entry] # for list creation @attribution_license_id = params[:attribution_license_id] # for list creation @items = self.deserialize(params[:items], :as => Smartfm::Item) @sentences = self.deserialize(params[:sentences], :as => Smartfm::Sentence) @user = self.deserialize(params[:user], :as => Smartfm::User) end |
Class Method Details
.rest_client ⇒ Object
12 |
# File 'lib/smartfm/models/list.rb', line 12 def self.rest_client; Smartfm::RestClient::List; end |
Instance Method Details
#add_item(auth, item) ⇒ Object
74 75 76 77 |
# File 'lib/smartfm/models/list.rb', line 74 def add_item(auth, item) # id is used for item_id only here.. self.rest_client.add_item(auth, {:list_id => self.id, :id => item.id}) end |
#delete_item(auth, item) ⇒ Object
79 80 81 |
# File 'lib/smartfm/models/list.rb', line 79 def delete_item(auth, item) self.rest_client.delete_item(auth, {:id => self.id, :item_id => item.id}) end |
#items(params = {}) ⇒ Object
64 65 66 67 |
# File 'lib/smartfm/models/list.rb', line 64 def items(params = {}) hash = self.rest_client.items(params.merge(:id => self.id)) self.deserialize(hash, :as => Smartfm::Item) || [] end |
#rest_client ⇒ Object
13 |
# File 'lib/smartfm/models/list.rb', line 13 def rest_client; self.class.rest_client; end |