Sha256: ee49ff6b4c70b0a6c7f3f5dd2a4de5d9f2550aa9cd77654b601ec5f7b2105ec7
Contents?: true
Size: 1.11 KB
Versions: 1
Compression:
Stored size: 1.11 KB
Contents
module ActsAsNestedInterval class Configuration attr_reader :foreign_key, :dependent, :scope_columns attr_accessor :moving # multiple_roots - allow more than one root def initialize( model, virtual_root: false, foreign_key: :parent_id, dependent: :restrict_with_exception, scope_columns: [], moveable: true) @multiple_roots = !!virtual_root @foreign_key = foreign_key.to_sym @dependent = dependent @scope_columns = *scope_columns @moveable = moveable && !model.readonly_attributes.include?(foreign_key) # Fix issue #9 @moving = false check_model_columns( model ) end def multiple_roots? @multiple_roots end def fraction_cache? @fraction_cache end def moveable? @moveable end private def check_model_columns( model ) if missing_column = Constants::REQUIRED_COLUMNS.detect { |col| !model.columns_hash.has_key?( col.to_s ) } raise Constants::MissingColumn.new( missing_column ) end @fraction_cache = [:lft, :rgt].all? { |col| model.columns_hash.has_key?( col.to_s ) } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
acts_as_nested_interval-0.3.0.pre | lib/acts_as_nested_interval/configuration.rb |