Module: ScaffoldSinatra::Utils

Includes:
Scaffolds
Defined in:
lib/scaffold_sinatra/utils.rb

Constant Summary

Constants included from Scaffolds

Scaffolds::BASIC, Scaffolds::FILE_SCAFFOLD, Scaffolds::FULL, Scaffolds::STANDARD

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Scaffolds

#scaffold_with_value, #scaffolds, #value_of

Class Method Details

.add_scaffold_methodsObject



7
8
9
10
11
12
13
# File 'lib/scaffold_sinatra/utils.rb', line 7

def self.add_scaffold_methods
  module_function(:scaffolds)
  scaffolds.each_key do |level_of|
    level = const_get(level_of.upcase)
    define_method(:"#{level_of}_scaffold?") { @value >= level }
  end
end

Instance Method Details

#include_in_scaffold?(file_name) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
32
# File 'lib/scaffold_sinatra/utils.rb', line 29

def include_in_scaffold?(file_name)
  scaffold = ScaffoldSinatra::Scaffolds::FILE_SCAFFOLD[file_name.to_s]
  ScaffoldSinatra::Scaffolds.const_get(scaffold.upcase) <= @value unless scaffold.nil?
end

#is_scaffold?(scaffold) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/scaffold_sinatra/utils.rb', line 25

def is_scaffold?(scaffold)
  !ScaffoldSinatra::Scaffolds.const_get(scaffold.upcase).nil?
end

#scaffoldObject



21
22
23
# File 'lib/scaffold_sinatra/utils.rb', line 21

def scaffold
  scaffold_with_value(@value)
end

#scaffold=(scaffold) ⇒ Object



17
18
19
# File 'lib/scaffold_sinatra/utils.rb', line 17

def scaffold=(scaffold)
  @value = value_of(scaffold)
end