Sha256: 37debb08f62c48fed8ccc470318f81795d08732b47399b4c685c76af952ee488

Contents?: true

Size: 1.89 KB

Versions: 10

Compression:

Stored size: 1.89 KB

Contents

<% # TODO mover para helper
base_path        = Rails.root.join('app', 'assets', 'javascripts', 'models')
models_list      = Dir.glob(Rails.root.join(base_path, '**', '*.js*'))
models_list.map! do |file|
   file.sub! base_path.to_s + '/', ''

   # Ignore Emacs temporary files
   next nil if file =~ /~/

   entries         = file.split /\// || []
   entries.unshift 'models'
   entries.push    File.basename entries.pop, '.js.coffee'
   File.join *entries

end.compact!

models_list.each do |model_file|
  require_asset model_file
end

%>


'use strict'

root = exports ? this

define 'aura/extensions/models', <%= models_list.to_json  %>, (models...) ->

  # TODO better require api for indemma
  indemma = require 'indemma'
  require 'indefinido-indemma/lib/extensions/rivets'
  require 'indefinido-indemma/lib/record/rest'
  require 'indefinido-indemma/lib/record/associable'
  require 'indefinido-indemma/lib/record/scopable'
  require 'indefinido-indemma/lib/record/restfulable'
  require 'indefinido-indemma/lib/record/resource'
  require 'indefinido-indemma/lib/record/maid'
  require 'indefinido-indemma/lib/record/validatable'


  # Extension definition
  initialize: (application) ->
    core                = application.core
    sandbox             = application.sandbox
    core.util.inflector =
      cssify: (sentence) ->  sentence.replace /\//, '-'

    # TODO rename core.models to core.domain, completely
    core.domain = core.models   = sandbox.models = indemma.model

    core.model  = sandbox.model = (name) ->
      # TODO use a Map internally in indemma
      model = indemma.model[name]
      throw new Error "Model '#{name}' not found!" unless model?
      model

    # TODO rename core.models to core.domain, completely
    core.domain.record = core.models.record = sandbox.models.record = indemma.record

    # build all model definitions
    core.util._.map models, (model) -> indemma.model.call model

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
ende-0.1.12 lib/assets/javascripts/aura/extensions/models.js.coffee.erb
ende-0.1.11 lib/assets/javascripts/aura/extensions/models.js.coffee.erb
ende-0.1.10 lib/assets/javascripts/aura/extensions/models.js.coffee.erb
ende-0.1.9 lib/assets/javascripts/aura/extensions/models.js.coffee.erb
ende-0.1.8 lib/assets/javascripts/aura/extensions/models.js.coffee.erb
ende-0.1.7 lib/assets/javascripts/aura/extensions/models.js.coffee.erb
ende-0.1.6 lib/assets/javascripts/aura/extensions/models.js.coffee.erb
ende-0.1.5 lib/assets/javascripts/aura/extensions/models.js.coffee.erb
ende-0.1.4 lib/assets/javascripts/aura/extensions/models.js.coffee.erb
ende-0.1.3 lib/assets/javascripts/aura/extensions/models.js.coffee.erb