Class: Personify::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/personify/context.rb

Overview

This specifies the context we can evaluate in

Direct Known Subclasses

DefaultContext

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.allow_method?(method_name) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/personify/context.rb', line 14

def allow_method?(method_name)
  self.allowed_context_methods.include?(method_name.to_sym)
end

.allowed_context_methodsObject



6
7
8
# File 'lib/personify/context.rb', line 6

def allowed_context_methods
  @allowed_methods ||= []
end

.context_method(method_name) ⇒ Object



10
11
12
# File 'lib/personify/context.rb', line 10

def context_method(method_name)
  self.allowed_context_methods << method_name.to_sym if self.instance_methods.include?(method_name.to_s) || self.instance_methods.include?(method_name.to_sym)
end

Instance Method Details

#[](k) ⇒ Object



31
32
33
# File 'lib/personify/context.rb', line 31

def [](k)
  self.local_assigns[k]
end

#allow_method?(method_name) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/personify/context.rb', line 19

def allow_method?(method_name)
  self.class.allow_method?(method_name)
end

#has_key?(k) ⇒ Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/personify/context.rb', line 35

def has_key?(k)
  self.local_assigns.has_key?(k)
end

#local_assignsObject



27
28
29
# File 'lib/personify/context.rb', line 27

def local_assigns
  @local_assigns ||= {}
end

#local_assigns=(assigns) ⇒ Object



23
24
25
# File 'lib/personify/context.rb', line 23

def local_assigns=(assigns)
  @local_assigns = assigns
end