Sha256: 376cca8995b85b89027b1726e35376f09276637b667ea01ddef36b2ebd051d0a

Contents?: true

Size: 482 Bytes

Versions: 10

Compression:

Stored size: 482 Bytes

Contents

module Kuztuscms
  class Settings
    class << self
      def set(key, value)
        Kuztuscms::Setting.create!(:key => key, :value => value)
        self.clear_cache
      end

      def clear_cache
        @cache = nil
      end

      def get(key)
        unless @cache
          @cache = Kuztuscms::Setting.all.inject({}) do |res, setting|
            res[setting.key] = setting.value

            res
          end
        end

        @cache[key]
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
kuztuscms-0.0.10 lib/kuztuscms/settings.rb
kuztuscms-0.0.9 lib/kuztuscms/settings.rb
kuztuscms-0.0.8 lib/kuztuscms/settings.rb
kuztuscms-0.0.7 lib/kuztuscms/settings.rb
kuztuscms-0.0.6 lib/kuztuscms/settings.rb
kuztuscms-0.0.5 lib/kuztuscms/settings.rb
kuztuscms-0.0.4 lib/kuztuscms/settings.rb
kuztuscms-0.0.3 lib/kuztuscms/settings.rb
kuztuscms-0.0.2 lib/kuztuscms/settings.rb
kuztuscms-0.0.1 lib/kuztuscms/settings.rb