Sha256: 7950a8c9490a74df21ba3c35dc7921199a2b3d952f83d6c4c446e821360b1cd3

Contents?: true

Size: 1.03 KB

Versions: 5

Compression:

Stored size: 1.03 KB

Contents

module Ixtlan
  module Controllers
    module WordBundlesController

      def self.included(base)
        # no guard since everyone needs to load the bundles
        base.skip_before_filter :guard
      end

      def index
        locale = params[:code]
        # TODO load in following order and allow to replace findings in the
        # intermediate result set
        # * DEFAULT not_approved
        # * DEFAULT latest_approved
        # * locale-parent latest_approved
        # * locale latest_approved
        l = Locale.first(:code => locale) || Locale.get!(locale)
        word_bundle = {}
        Ixtlan::Models::Word.not_approved(:locale => Locale.default).each do |word|
          word_bundle[word.code] = word
        end
        Ixtlan::Models::Word.approved(:locale => Locale.default).each do |word|
          word_bundle[word.code] = word
        end

        render :xml => "<word_bundle><locale>#{locale}</locale><words>" + word_bundle.values.collect { |w| w.to_xml }.join + "</words></word_bundle>" 
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ixtlan-0.4.0.pre4 lib/ixtlan/controllers/word_bundles_controller.rb
ixtlan-0.4.0.pre3 lib/ixtlan/controllers/word_bundles_controller.rb
ixtlan-0.4.0.pre2 lib/ixtlan/controllers/word_bundles_controller.rb
ixtlan-0.4.0.pre lib/ixtlan/controllers/word_bundles_controller.rb
ixtlan-0.3.0 lib/ixtlan/controllers/word_bundles_controller.rb