Class: SkipEmbedded::FulltextSearchCache::BuilderBase

Inherits:
Object
  • Object
show all
Includes:
ActionController::UrlWriter
Defined in:
lib/skip_embedded/fulltext_search_cache/builder_base.rb

Instance Method Summary collapse

Constructor Details

#initialize(entity) ⇒ BuilderBase

Returns a new instance of BuilderBase.



8
9
10
# File 'lib/skip_embedded/fulltext_search_cache/builder_base.rb', line 8

def initialize(entity)
  @entity = entity
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args, &block) ⇒ Object (private)



45
46
47
48
# File 'lib/skip_embedded/fulltext_search_cache/builder_base.rb', line 45

def method_missing(m, *args, &block)
  return @entity if m.to_sym == entity_name.to_sym
  super
end

Instance Method Details

#bodyObject

Raises:

  • (NotImplementedError)


38
# File 'lib/skip_embedded/fulltext_search_cache/builder_base.rb', line 38

def body; raise NotImplementedError, "ovverride me" end

#filenameObject



12
13
14
# File 'lib/skip_embedded/fulltext_search_cache/builder_base.rb', line 12

def filename
  "#{entity_name}/#{@entity.id}.html"
end

#icon_url(icon_filename = entity_name + ".gif") ⇒ Object



40
41
42
# File 'lib/skip_embedded/fulltext_search_cache/builder_base.rb', line 40

def icon_url(icon_filename = entity_name + ".gif")
  root_url + "images/icons/" + icon_filename
end

#titleObject

Raises:

  • (NotImplementedError)


37
# File 'lib/skip_embedded/fulltext_search_cache/builder_base.rb', line 37

def title; raise NotImplementedError, "ovverride me" end

#to_cacheObject



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/skip_embedded/fulltext_search_cache/builder_base.rb', line 20

def to_cache
  ERB.new(<<-HTML).result(binding)
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>#{title}</title>
  </head>
  <body>#{body}</body>
</html>
HTML
end

#to_metaObject

Raises:

  • (NotImplementedError)


36
# File 'lib/skip_embedded/fulltext_search_cache/builder_base.rb', line 36

def to_meta; raise NotImplementedError, "ovverride me" end

#write_cache(mediator) ⇒ Object



16
17
18
# File 'lib/skip_embedded/fulltext_search_cache/builder_base.rb', line 16

def write_cache(mediator)
  File.open(mediator.cache_path(self), "wb"){|f| f.write to_cache }
end

#write_meta(mediator) ⇒ Object



32
33
34
# File 'lib/skip_embedded/fulltext_search_cache/builder_base.rb', line 32

def write_meta(mediator)
  File.open(mediator.meta_path(self), "wb"){|f| f.write to_meta.to_yaml }
end