Class: PolicyManager::Script
- Inherits:
-
Object
- Object
- PolicyManager::Script
- Includes:
- ActiveModel::Serialization
- Defined in:
- lib/policy_manager/script.rb
Instance Attribute Summary collapse
-
#cookies ⇒ Object
Returns the value of attribute cookies.
-
#description ⇒ Object
Returns the value of attribute description.
-
#domain ⇒ Object
Returns the value of attribute domain.
-
#environments ⇒ Object
Returns the value of attribute environments.
-
#name ⇒ Object
Returns the value of attribute name.
-
#permanent ⇒ Object
Returns the value of attribute permanent.
-
#script ⇒ Object
Returns the value of attribute script.
Class Method Summary collapse
Instance Method Summary collapse
- #as_json(opts = {}) ⇒ Object
- #can_render? ⇒ Boolean
-
#initialize(opts = {}) ⇒ Script
constructor
A new instance of Script.
Constructor Details
#initialize(opts = {}) ⇒ Script
Returns a new instance of Script.
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/policy_manager/script.rb', line 13 def initialize(opts={}) self.name = opts[:name] self.script = opts[:script] self. = opts[:cookies] self.environments = opts[:environments] self.description = opts[:description] self.permanent = opts[:permanent] self.domain = opts[:domain] self end |
Instance Attribute Details
#cookies ⇒ Object
Returns the value of attribute cookies.
5 6 7 |
# File 'lib/policy_manager/script.rb', line 5 def @cookies end |
#description ⇒ Object
Returns the value of attribute description.
5 6 7 |
# File 'lib/policy_manager/script.rb', line 5 def description @description end |
#domain ⇒ Object
Returns the value of attribute domain.
5 6 7 |
# File 'lib/policy_manager/script.rb', line 5 def domain @domain end |
#environments ⇒ Object
Returns the value of attribute environments.
5 6 7 |
# File 'lib/policy_manager/script.rb', line 5 def environments @environments end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/policy_manager/script.rb', line 5 def name @name end |
#permanent ⇒ Object
Returns the value of attribute permanent.
5 6 7 |
# File 'lib/policy_manager/script.rb', line 5 def permanent @permanent end |
#script ⇒ Object
Returns the value of attribute script.
5 6 7 |
# File 'lib/policy_manager/script.rb', line 5 def script @script end |
Class Method Details
.cookies ⇒ Object
39 40 41 42 43 |
# File 'lib/policy_manager/script.rb', line 39 def self. PolicyManager::Config .scripts .select{|o| o..present? } end |
.cookies_permanent ⇒ Object
45 46 47 48 49 |
# File 'lib/policy_manager/script.rb', line 45 def self. PolicyManager::Config .scripts .select{|o| o..present? && o.permanent? } end |
.scripts ⇒ Object
51 52 53 |
# File 'lib/policy_manager/script.rb', line 51 def self.scripts PolicyManager::Config.scripts.select{|o| o.script.present?} end |
Instance Method Details
#as_json(opts = {}) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/policy_manager/script.rb', line 32 def as_json(opts={}) data = {} fields = [:script, :name, :cookies, :description] fields.each { |k| data[k] = send(k) } data end |
#can_render? ⇒ Boolean
24 25 26 |
# File 'lib/policy_manager/script.rb', line 24 def can_render? self.environments.map(&:to_s).include?(Rails.env) end |