Class: Exlibris::Primo::Tags

Inherits:
Object
  • Object
show all
Includes:
ChainGang::Base, ChainGang::Record, ChainGang::User, Config::Attributes, RequestAttributes, WriteAttributes
Defined in:
lib/exlibris/primo/tags.rb

Overview

Manipulate a Primo tags using Exlibris::Primo::Tags

tags = Tags.new.base_url!("http://primo.library.edu").institution!("PRIMO").
  user_id!("USER_ID").record_id!("aleph0123456789")
tag.my_tags #=> Array of Primo tags

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from WriteAttributes

#write_attributes

Methods included from ChainGang::Record

#record_id!

Methods included from ChainGang::User

#user_id!

Methods included from ChainGang::Base

#base_url!, #group!, #institution!, #ip!, #logged_in, #logged_out, #off_campus, #on_campus, #pds_handle!

Methods included from Config::Attributes

#availability_statuses, #base_url, #config, #facet_collections, #facet_labels, #facet_resource_types, #facet_top_level, #institution, #institutions, #libraries, #sources

Constructor Details

#initialize(*args) ⇒ Tags

Returns a new instance of Tags.


20
21
22
# File 'lib/exlibris/primo/tags.rb', line 20

def initialize *args
  super
end

Instance Attribute Details

#record_idObject (readonly)

Returns the value of attribute record_id


18
19
20
# File 'lib/exlibris/primo/tags.rb', line 18

def record_id
  @record_id
end

#user_idObject (readonly)

Returns the value of attribute user_id


18
19
20
# File 'lib/exlibris/primo/tags.rb', line 18

def user_id
  @user_id
end

Instance Method Details

#add_tag(tag) ⇒ Object

Call web service to add a tag to Primo for the specified record


58
59
60
61
# File 'lib/exlibris/primo/tags.rb', line 58

def add_tag(tag)
  Exlibris::Primo::WebService::Request::AddTag.new(user_record_request_attributes.merge :value => tag).call
  reset_tags
end

#add_tags(tags) ⇒ Object

Call web service to add tags to Primo for the specified record


49
50
51
52
53
# File 'lib/exlibris/primo/tags.rb', line 49

def add_tags(tags)
  tags.each do |tag|
    add_tag tag
  end
end

#record_tagsObject

Get all tags for the specified user


34
35
36
# File 'lib/exlibris/primo/tags.rb', line 34

def record_tags
  @record_tags ||= get_tags.everybody_tags
end

#remove_tag(tag) ⇒ Object

Call web service to remove tag from Primo for the specified record


75
76
77
78
# File 'lib/exlibris/primo/tags.rb', line 75

def remove_tag(tag)
  Exlibris::Primo::WebService::Request::RemoveTag.new(user_record_request_attributes.merge :value => tag).call
  reset_tags
end

#remove_tags(tags) ⇒ Object

Call web service to remove tags from Primo for the specified record


66
67
68
69
70
# File 'lib/exlibris/primo/tags.rb', line 66

def remove_tags(tags)
  tags.each do |tag|
    remove_tag tag
  end
end

#remove_user_tagsObject

Remove all users tags


83
84
85
86
# File 'lib/exlibris/primo/tags.rb', line 83

def remove_user_tags
  Exlibris::Primo::WebService::Request::RemoveUserTags.new(user_request_attributes).call
  reset_tags
end

#tagsObject

Get tags for the specified user and record


27
28
29
# File 'lib/exlibris/primo/tags.rb', line 27

def tags
  @tags ||= get_tags.my_tags
end

#user_tagsObject

Get all tags for the specified user


41
42
43
44
# File 'lib/exlibris/primo/tags.rb', line 41

def user_tags
  @user_tags ||= 
    Exlibris::Primo::WebService::Request::GetAllMyTags.new(user_request_attributes).call.my_tags
end