Module: MultiSite::ScopedModel::ClassMethods
- Defined in:
- lib/multi_site/scoped_model.rb
Instance Method Summary collapse
-
#is_site_scoped(options = {}) ⇒ Object
only option at the moment is :shareable, which we take to mean that sites are optional: if true it causes us not to set the site automatically or to validate its presence, and to extend the scoping conditions so that objects with no site are returned as well as objects with the specified site that is, anything without a site is considered to be shared among all sites the default is false.
- #is_site_scoped? ⇒ Boolean
Instance Method Details
#is_site_scoped(options = {}) ⇒ Object
only option at the moment is :shareable, which we take to mean that sites are optional: if true it causes us not to set the site automatically or to validate its presence, and to extend the scoping conditions so that objects with no site are returned as well as objects with the specified site that is, anything without a site is considered to be shared among all sites the default is false
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/multi_site/scoped_model.rb', line 20 def is_site_scoped(={}) return if is_site_scoped? = { :shareable => false }.merge() class_eval " default_scope {where(site_scope_condition)}\n extend MultiSite::ScopedModel::ScopedClassMethods\n include MultiSite::ScopedModel::ScopedInstanceMethods\n EO\n \n belongs_to :site\n Site.send(:has_many, plural_symbol_for_class)\n\n before_validation :set_site\n validates_presence_of :site unless options[:shareable]\n\n class << self\n attr_accessor :shareable\n alias_method_chain :paginate, :site\n %w{count average minimum maximum sum}.each do |getter|\n alias_method_chain getter.intern, :site\n end\n end\n \n self.shareable = options[:shareable]\nend\n" |
#is_site_scoped? ⇒ Boolean
9 10 11 |
# File 'lib/multi_site/scoped_model.rb', line 9 def is_site_scoped? false end |