Class: Pluto::Model::Feed
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Pluto::Model::Feed
show all
- Includes:
- ActiveRecordMethods
- Defined in:
- lib/pluto/models/feed.rb
Class Method Summary
collapse
Instance Method Summary
collapse
#read_attribute_w_fallbacks
Class Method Details
.latest ⇒ Object
17
18
19
20
21
22
23
24
|
# File 'lib/pluto/models/feed.rb', line 17
def self.latest
order( "coalesce(feeds.last_published,'1971-01-01') desc" )
end
|
Instance Method Details
#debug=(value) ⇒ Object
63
|
# File 'lib/pluto/models/feed.rb', line 63
def debug=(value) @debug = value; end
|
#debug? ⇒ Boolean
64
|
# File 'lib/pluto/models/feed.rb', line 64
def debug?() @debug || false; end
|
#description ⇒ Object
alias for summary – also add descr shortcut??
32
|
# File 'lib/pluto/models/feed.rb', line 32
def description() summary; end
|
#feed ⇒ Object
34
|
# File 'lib/pluto/models/feed.rb', line 34
def feed() feed_url; end
|
#feed_url ⇒ Object
44
|
# File 'lib/pluto/models/feed.rb', line 44
def feed_url() read_attribute_w_fallbacks( :feed_url, :auto_feed_url ); end
|
#feed_url? ⇒ Boolean
39
|
# File 'lib/pluto/models/feed.rb', line 39
def feed_url?() read_attribute(:feed_url).present?; end
|
#link ⇒ Object
33
|
# File 'lib/pluto/models/feed.rb', line 33
def link() url; end
|
#name ⇒ Object
attribute reader aliases
todo: check if we can use alias_method :name, :title - works for non-existing/on-demand-generated method too??
31
|
# File 'lib/pluto/models/feed.rb', line 31
def name() title; end
|
#published ⇒ Object
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/pluto/models/feed.rb', line 51
def published
read_attribute_w_fallbacks(
:published,
:touched, :built )
end
|
#published? ⇒ Boolean
47
|
# File 'lib/pluto/models/feed.rb', line 47
def published?() read_attribute(:published).present?; end
|
#save_from_struct!(data) ⇒ Object
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
# File 'lib/pluto/models/feed.rb', line 66
def save_from_struct!( data )
update_from_struct!( data )
data.items.each do |item|
item_rec = Item.find_by_guid( item.guid )
if item_rec.nil?
item_rec = Item.new
puts "** NEW | #{item.title}"
else
puts "UPDATE | #{item.title}"
end
item_rec.debug = debug? ? true : false item_rec.update_from_struct!( self, item )
end end
|
#title ⇒ Object
42
|
# File 'lib/pluto/models/feed.rb', line 42
def title() read_attribute_w_fallbacks( :title, :auto_title ); end
|
#title2 ⇒ Object
43
|
# File 'lib/pluto/models/feed.rb', line 43
def title2() read_attribute_w_fallbacks( :title2, :auto_title2 ); end
|
#title2? ⇒ Boolean
38
|
# File 'lib/pluto/models/feed.rb', line 38
def title2?() read_attribute(:title2).present?; end
|
#title? ⇒ Boolean
37
|
# File 'lib/pluto/models/feed.rb', line 37
def title?() read_attribute(:title).present?; end
|
#touched? ⇒ Boolean
48
|
# File 'lib/pluto/models/feed.rb', line 48
def touched?() read_attribute(:touched).present?; end
|
#update_from_struct!(data) ⇒ Object
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
# File 'lib/pluto/models/feed.rb', line 88
def update_from_struct!( data )
if data.generator
generator_full = ''
generator_full << data.generator
generator_full << " @version=#{data.generator_version}" if data.generator_version
generator_full << " @uri=#{data.generator_uri}" if data.generator_uri
else
generator_full = nil
end
feed_attribs = {
format: data.format,
published: data.published,
touched: data.updated,
built: data.built,
summary: data.summary,
auto_title2: data.title2,
generator: generator_full
}
if debug?
puts "*** dump feed_attribs w/ class types:"
feed_attribs.each do |key,value|
puts " #{key}: >#{value}< : #{value.class.name}"
end
end
update_attributes!( feed_attribs )
end
|
#url ⇒ Object
41
|
# File 'lib/pluto/models/feed.rb', line 41
def url() read_attribute_w_fallbacks( :url, :auto_url ); end
|
#url? ⇒ Boolean
36
|
# File 'lib/pluto/models/feed.rb', line 36
def url?() read_attribute(:url).present?; end
|