Class: Rapid::Skeleton::Base
- Inherits:
-
Object
- Object
- Rapid::Skeleton::Base
- Includes:
- ActiveModel::Validations, Helpers::Directory, Helpers::Files, Helpers::Gem, Helpers::IfSetting, Helpers::Migration, Helpers::Route, Helpers::Script, Helpers::Template, Helpers::View
- Defined in:
- lib/rapid/skeleton/base.rb
Instance Attribute Summary collapse
-
#check ⇒ Object
readonly
Returns the value of attribute check.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#project_path ⇒ Object
readonly
Returns the value of attribute project_path.
-
#settings ⇒ Object
Returns the value of attribute settings.
-
#templates_path ⇒ Object
readonly
Returns the value of attribute templates_path.
Instance Method Summary collapse
- #[]=(key, value) ⇒ Object
-
#initialize(settings = nil, options = {}) ⇒ Base
constructor
A new instance of Base.
- #pull ⇒ Object
- #pull! ⇒ Object
- #push(settings = nil) ⇒ Object
- #push!(settings = nil) ⇒ Object
Methods included from Helpers::Route
Constructor Details
#initialize(settings = nil, options = {}) ⇒ Base
Returns a new instance of Base.
31 32 33 34 35 36 37 38 |
# File 'lib/rapid/skeleton/base.rb', line 31 def initialize settings = nil, = {} @settings = settings @project_path = [:project_path] || File.('.') @templates_path = [:templates_path] || discover_templates_path([:file]) @name = [:name] || implied_name @check = [:check] || Rapid::Check.current || Rapid::Check.new("", ) end |
Instance Attribute Details
#check ⇒ Object (readonly)
Returns the value of attribute check.
18 19 20 |
# File 'lib/rapid/skeleton/base.rb', line 18 def check @check end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
18 19 20 |
# File 'lib/rapid/skeleton/base.rb', line 18 def name @name end |
#project_path ⇒ Object (readonly)
Returns the value of attribute project_path.
18 19 20 |
# File 'lib/rapid/skeleton/base.rb', line 18 def project_path @project_path end |
#settings ⇒ Object
Returns the value of attribute settings.
18 19 20 |
# File 'lib/rapid/skeleton/base.rb', line 18 def settings @settings end |
#templates_path ⇒ Object (readonly)
Returns the value of attribute templates_path.
18 19 20 |
# File 'lib/rapid/skeleton/base.rb', line 18 def templates_path @templates_path end |
Instance Method Details
#[]=(key, value) ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/rapid/skeleton/base.rb', line 82 def []= key, value # if this is the first time this setting has been set if @pulled_settings.nil? || !@pulled_settings.include?(key) @pulled_settings.push key if @pulled_settings @check.log_value :info, key, value @settings[key] = value else old_value = @settings[key] old_value = old_value.on? if old_value.is_a?(Setting::Namespace::Instance) @settings[key] = value new_value = @settings[key] new_value = new_value.on? if new_value.is_a?(Setting::Namespace::Instance) if old_value == new_value @check.log_value :info, key, value else @check.log_value :warning, key, value end end end |
#pull ⇒ Object
73 74 75 76 77 78 79 80 |
# File 'lib/rapid/skeleton/base.rb', line 73 def pull @pulling = true @pulled_settings = [] !@check.encounters_error? { section(name) { bones } } ensure @pulling = false @pulled_settings = nil end |
#pull! ⇒ Object
65 66 67 68 69 70 71 |
# File 'lib/rapid/skeleton/base.rb', line 65 def pull! if pull true else raise Rapid::InvalidSkeletonError.new(self.class.name) end end |
#push(settings = nil) ⇒ Object
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/rapid/skeleton/base.rb', line 54 def push settings = nil self.settings = settings if settings @pushing = true is_valid = valid? section(name) { bones } if is_valid is_valid ensure @pushing = false end |
#push!(settings = nil) ⇒ Object
44 45 46 47 48 49 50 51 52 |
# File 'lib/rapid/skeleton/base.rb', line 44 def push! settings = nil if push(settings) true else raise Rapid::InvalidSkeletonError.new(errors..join(', ')) end true end |