Class: Postal::Content

Inherits:
Object
  • Object
show all
Defined in:
lib/postal/content.rb

Constant Summary collapse

DEFAULT_ATTRIBUTES =
{:content_id => nil,
:date_created => nil,
:description => nil,
:doc_parts => nil,
:doc_type => nil,
:header_from => nil,
:header_to => nil,
:is_read_only => nil,
:is_template => nil,
:list_name => nil,
:native_title => nil,
:site_name => nil,
:title => nil}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Content

Create a new member instance



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/postal/content.rb', line 63

def initialize(attributes={})
  attributes = DEFAULT_ATTRIBUTES.merge(attributes)
  @content_id = attributes[:content_id]
  @date_created = attributes[:date_created]
  @description = attributes[:description]
  @doc_parts = attributes[:doc_parts]
  @doc_type = attributes[:doc_type]
  @header_from = attributes[:header_from]
  @header_to = attributes[:header_to]
  @is_read_only = attributes[:is_read_only]
  @is_template = attributes[:is_template]
  @list_name = attributes[:list_name]
  @native_title = attributes[:native_title]
  @site_name = attributes[:site_name]
  @title = attributes[:title]
end

Instance Attribute Details

#content_idObject

Returns the value of attribute content_id.



59
60
61
# File 'lib/postal/content.rb', line 59

def content_id
  @content_id
end

#date_createdObject

Returns the value of attribute date_created.



59
60
61
# File 'lib/postal/content.rb', line 59

def date_created
  @date_created
end

#descriptionObject

Returns the value of attribute description.



59
60
61
# File 'lib/postal/content.rb', line 59

def description
  @description
end

#doc_partsObject

Returns the value of attribute doc_parts.



59
60
61
# File 'lib/postal/content.rb', line 59

def doc_parts
  @doc_parts
end

#doc_typeObject

Returns the value of attribute doc_type.



59
60
61
# File 'lib/postal/content.rb', line 59

def doc_type
  @doc_type
end

#header_fromObject

Returns the value of attribute header_from.



59
60
61
# File 'lib/postal/content.rb', line 59

def header_from
  @header_from
end

#header_toObject

Returns the value of attribute header_to.



59
60
61
# File 'lib/postal/content.rb', line 59

def header_to
  @header_to
end

#is_read_onlyObject

Returns the value of attribute is_read_only.



59
60
61
# File 'lib/postal/content.rb', line 59

def is_read_only
  @is_read_only
end

#is_templateObject

Returns the value of attribute is_template.



59
60
61
# File 'lib/postal/content.rb', line 59

def is_template
  @is_template
end

#list_nameObject

Returns the value of attribute list_name.



59
60
61
# File 'lib/postal/content.rb', line 59

def list_name
  @list_name
end

#native_titleObject

Returns the value of attribute native_title.



59
60
61
# File 'lib/postal/content.rb', line 59

def native_title
  @native_title
end

#site_nameObject

Returns the value of attribute site_name.



59
60
61
# File 'lib/postal/content.rb', line 59

def site_name
  @site_name
end

#titleObject

Returns the value of attribute title.



59
60
61
# File 'lib/postal/content.rb', line 59

def title
  @title
end

Class Method Details

.find_allObject

really just an alias for find_by_filter but with no options



38
39
40
# File 'lib/postal/content.rb', line 38

def find_all
  find_by_filter
end

.find_by_filter(*args) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/postal/content.rb', line 6

def find_by_filter(*args)
  unless args.find { |arg| arg.match(/ListName/) }
    args << "ListName=#{Postal.options[:list_name]}"
  end
  if soap_contents = Postal.driver.selectContent(args)[:item]
    contents = soap_contents.collect do |content|
      Content.new(:content_id => content[:content_id],
                  :date_created => content[:date_created], 
                  :description => content[:description], 
                  :doc_parts => content[:doc_parts], 
                  :doc_type => content[:doc_yype],
                  :header_from => content[:header_from],
                  :header_to => content[:header_to],
                  :is_read_only => content[:is_read_only],
                  :is_template => content[:is_template],
                  :list_name => content[:list_name],
                  :native_title => content[:native_title],
                  :site_name => content[:site_name],
                  :title => content[:title])
    end
    if contents.size == 1
      return contents.first
    else
      return contents
    end
  else
    return nil
  end
end