Sha256: ee1160e929ae5208ff48b9d8244270d58e61ba8c8d2f444687b290718d0cdb9b

Contents?: true

Size: 1.15 KB

Versions: 4

Compression:

Stored size: 1.15 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

        base.cache_headers :protected
      end

      private

      LOCALE = Object.full_const_get(::Ixtlan::Models::LOCALE)

      public

      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

4 entries across 4 versions & 1 rubygems

Version Path
ixtlan-0.4.3 lib/ixtlan/controllers/word_bundles_controller.rb
ixtlan-0.4.2 lib/ixtlan/controllers/word_bundles_controller.rb
ixtlan-0.4.1 lib/ixtlan/controllers/word_bundles_controller.rb
ixtlan-0.4.0 lib/ixtlan/controllers/word_bundles_controller.rb