Sha256: 19139795e8654d5d5580016fd1f40292cf60fdb72ebe5ded0086bf2edfcaa2e5

Contents?: true

Size: 1.21 KB

Versions: 6

Compression:

Stored size: 1.21 KB

Contents

#
# Filters registration routines
#
# @mixin
#
Joosy.Modules.Filters =

  #
  # Defines static registration routines
  #
  # @example Set of methods
  #   class Test
  #     @beforeLoad ->  # supposed to run before load and control loading queue
  #     @afterLoad ->   # supposed to run after load to finalize loading
  #     @afterUnload -> # supposed to run after unload to collect garbage
  #
  #     # private
  #
  #     @__runBeforeLoads() # Runs filters registered as beforeLoad
  #     @__runAfterLoads() # Runs filters registered as afterLoad
  #     @__runAfterUnloads() # Runs filters registered as afterUnload
  #
  included: ->
    ['beforeLoad', 'afterLoad', 'afterUnload'].each (filter) =>
      @[filter] = (callback) ->
        unless @::hasOwnProperty "__#{filter}s"
          @::["__#{filter}s"] = [].concat @.__super__["__#{filter}s"] || []
        @::["__#{filter}s"].push callback


['beforeLoad', 'afterLoad', 'afterUnload'].each (filter) =>
  Joosy.Modules.Filters["__run#{filter.camelize(true)}s"] = (opts...) ->
    return true unless @["__#{filter}s"]

    @["__#{filter}s"].reduce (flag, func) =>
      unless Object.isFunction func
        func = @[func]
      flag && func.apply(@, opts) != false
    , true

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
joosy-1.0.0.RC6 app/assets/javascripts/joosy/core/modules/filters.js.coffee
joosy-1.0.0.RC5 app/assets/javascripts/joosy/core/modules/filters.js.coffee
joosy-1.0.0.RC4 app/assets/javascripts/joosy/core/modules/filters.js.coffee
joosy-1.0.0.RC3 app/assets/javascripts/joosy/core/modules/filters.js.coffee
joosy-1.0.0.RC2 app/assets/javascripts/joosy/core/modules/filters.js.coffee
joosy-1.0.0.RC1 app/assets/javascripts/joosy/core/modules/filters.js.coffee