Class: Knish::ExistingModels
- Inherits:
-
Struct
- Object
- Struct
- Knish::ExistingModels
- Defined in:
- lib/knish/existing_models.rb
Defined Under Namespace
Classes: Data
Instance Attribute Summary collapse
-
#path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path
2 3 4 |
# File 'lib/knish/existing_models.rb', line 2 def path @path end |
Instance Method Details
#data ⇒ Object
15 16 17 18 19 |
# File 'lib/knish/existing_models.rb', line 15 def data paths.map { |path| Data.new(id(path), path) if id(path) }.compact end |
#id(path) ⇒ Object
21 22 23 24 |
# File 'lib/knish/existing_models.rb', line 21 def id(path) last = path.split('/').last last && last.to_i end |
#ids ⇒ Object
7 8 9 |
# File 'lib/knish/existing_models.rb', line 7 def ids paths.map{|path| id(path) }.compact end |
#next_id ⇒ Object
3 4 5 |
# File 'lib/knish/existing_models.rb', line 3 def next_id (ids.max || 0) + 1 end |
#paths ⇒ Object
11 12 13 |
# File 'lib/knish/existing_models.rb', line 11 def paths Dir.glob("#{path}/*") end |