Sha256: c5e9e079b7cbb64733998f7635bd725b550990505c911ceaf92e66c2b5f5c675

Contents?: true

Size: 1.23 KB

Versions: 1

Compression:

Stored size: 1.23 KB

Contents

Joosy.Modules.Filters =
  included: ->
    @beforeLoad = (callback) ->
      unless @::hasOwnProperty '__beforeLoads'
        @::__beforeLoads = [].concat @.__super__.__beforeLoads || []
      @::__beforeLoads.push callback

    @afterLoad = (callback) ->
      unless @::hasOwnProperty '__afterLoads'
        @::__afterLoads = [].concat @.__super__.__afterLoads || []
      @::__afterLoads.push callback

    @afterUnload = (callback) ->
      unless @::hasOwnProperty '__afterUnloads'
        @::__afterUnloads = [].concat @.__super__.__afterUnloads || []
      @::__afterUnloads.push callback

  __runBeforeLoads: (opts...) ->
    unless @__beforeLoads?.length > 0
      return true

    flag = true

    for filter in @__beforeLoads
      unless Object.isFunction filter
        filter = @[filter]
      flag = flag && filter.apply @, opts

    return flag

  __runAfterLoads: (opts...) ->
    if @__afterLoads?.length > 0
      for filter in @__afterLoads
        unless Object.isFunction filter
          filter = @[filter]
        filter.apply @, opts

  __runAfterUnloads: (opts...) ->
    if @__afterUnloads?.length > 0
      for filter in @__afterUnloads
        unless Object.isFunction filter
          filter = @[filter]
        filter.apply @, opts

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
joosy-0.1.0.RC2 app/assets/javascripts/joosy/core/modules/filters.js.coffee