Sha256: 7d8d22e7a3aa736326304c3c3dcc0dce10140d6998ce3ff5653743de98891174

Contents?: true

Size: 591 Bytes

Versions: 7

Compression:

Stored size: 591 Bytes

Contents

Luca.concerns.ModelPresenter = 
  classMethods:
    getPresenter: (format)->
      @presenters?[format]

    registerPresenter: (format, config)->
      @presenters ||= {} 
      @presenters[ format ] = config

  presentAs: (format)->
    try
      attributeList = @componentMetaData().componentDefinition().getPresenter(format) 

      return @toJSON() unless attributeList?

      _( attributeList ).reduce (memo, attribute)=>
        memo[ attribute ] = @read(attribute)
        memo 
      , {}

    catch e
      console.log "Error presentAs", e.stack, e.message
      return @toJSON()

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
luca-0.9.91 app/assets/javascripts/luca/concerns/model_presenter.coffee
luca-0.9.9 app/assets/javascripts/luca/concerns/model_presenter.coffee
luca-0.9.899 app/assets/javascripts/luca/concerns/model_presenter.coffee
luca-0.9.89 app/assets/javascripts/luca/concerns/model_presenter.coffee
luca-0.9.8 app/assets/javascripts/luca/concerns/model_presenter.coffee
luca-0.9.76 src/concerns/model_presenter.coffee
luca-0.9.7 src/concerns/model_presenter.coffee