Sha256: 70d6c5d2bab131e68c4a287da20621b849573b49330db0f0722e39bc0c229b38
Contents?: true
Size: 852 Bytes
Versions: 17
Compression:
Stored size: 852 Bytes
Contents
module Locomotive::Steam module Models class Scope attr_accessor :site, :locale, :context def initialize(site, locale, context = nil) @site, @locale, @context = site, locale, (context || {}) end def default_locale site.try(:default_locale) end def locales site.try(:locales) end def with_locale(locale, &block) @previous_locale = @locale @locale = locale yield.tap do @locale = @previous_locale end end def apply(attributes) attributes['site_id'] = @site._id end def to_key (@site ? ['site', @site._id] : []).tap do |base| @context.each do |name, object| base << [name, object.try(:_id)] end end.flatten.join('_') end end end end
Version data entries
17 entries across 17 versions & 1 rubygems