Class: Base4R::UniversalItem
Overview
Item with a minimal set of Attributes, extend for specific Item Types
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Item
#attributes, #base_id, #draft, #title, #unique_id
Instance Method Summary collapse
-
#initialize(*args) ⇒ UniversalItem
constructor
Create a new UniversalItem, with unique_id, created by author_name who’s email is author_email, described by description, found at URL link, entitled title, phone number is contact_phone, item type is item_type, target_country e.g.
Methods inherited from Item
#draft?, #options_from_value, #to_xml
Methods included from ItemAttributeMethods
Constructor Details
#initialize(*args) ⇒ UniversalItem
Create a new UniversalItem, with unique_id, created by author_name who’s email is author_email, described by description, found at URL link, entitled title, phone number is contact_phone, item type is item_type, target_country e.g. ‘GB’, item_language e.g. ‘EN’
Args can also be a hash of attributes
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 |
# File 'lib/item.rb', line 216 def initialize(*args) = (args) #allow an option to specify which columns are private private_attributes = [.delete(:private_attributes)].flatten.inject([]){|list, val| list << val.to_s if val; list}.uniq @title = .delete(:title) self.draft = .delete(:draft) @attributes = [] .each do |key, value| v = (value, :private_attribute => private_attributes.include?(key.to_s)) #back support for author name and email if value && [:author_name, :author_email].include?(key.to_sym) send "#{key}=", value else add_attribute key, v end end end |