Module: PebblePath
- Defined in:
- lib/pebble_path.rb,
lib/pebble_path/positions.rb
Defined Under Namespace
Classes: Positions
Instance Attribute Summary collapse
-
#path ⇒ Object
Returns the value of attribute path.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path.
26 27 28 |
# File 'lib/pebble_path.rb', line 26 def path @path end |
Class Method Details
.detect(paths) ⇒ Object
9 10 11 |
# File 'lib/pebble_path.rb', line 9 def self.detect(paths) Positions.detect(paths) end |
.included(base) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/pebble_path.rb', line 13 def self.included(base) base.class_eval do scope :by_path, lambda { |path| where Positions.detect(path) } validates_presence_of :label_0 validate :must_be_valid_uid_path after_initialize :initialize_path end end |
.max_depth ⇒ Object
5 6 7 |
# File 'lib/pebble_path.rb', line 5 def self.max_depth Positions::MAX_DEPTH end |
Instance Method Details
#initialize_path ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/pebble_path.rb', line 36 def initialize_path positions = [] [:label_0, :label_1, :label_2, :label_3, :label_4, :label_5, :label_6, :label_7, :label_8, :label_9].each do |attribute| positions << send(attribute) end self.path = positions end |
#must_be_valid_uid_path ⇒ Object
44 45 46 47 48 |
# File 'lib/pebble_path.rb', line 44 def must_be_valid_uid_path unless Pebblebed::Uid.valid_path?(self.path.to_s) errors.add(:base, "Location path '#{self.path.to_s}' is invalid.") end end |