Class: RenderSync::ERBTracker

Inherits:
Object
  • Object
show all
Defined in:
lib/render_sync/erb_tracker.rb

Constant Summary collapse

SYNC_DEPENDENCY =

Matches:

sync partial: "comment", collection: commentable.comments
sync partial: "comment", resource: comment
/
  sync(?:_new)?\s*                         # sync or sync_new, followed by optional whitespace
  \(?\s*                                   # start an optional parenthesis for the sync call
  (?:partial:|:partial\s+=>)\s*            # naming the partial, used with collection
  ["']([a-z][a-z_\/]+)["']\s*              # the template name itself -- 1st capture
  ,\s*                                     # comma separating parameters
  :?(?:resource|collection)(?::|\s+=>)\s*  # resource or collection identifier
  @?(?:[a-z]+\.)*([a-z]+)                  # the resource or collection itself -- 2nd capture
/x

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.call(name, template) ⇒ Object



29
30
31
# File 'lib/render_sync/erb_tracker.rb', line 29

def self.call(name, template)
  new(name, template).dependencies
end

Instance Method Details

#dependenciesObject



33
34
35
# File 'lib/render_sync/erb_tracker.rb', line 33

def dependencies
  (sync_dependencies + super).uniq
end