Class: Bobkit::Scope

Inherits:
Object
  • Object
show all
Includes:
SlimBridge
Defined in:
lib/bobkit/scope.rb

Instance Method Summary collapse

Methods included from SlimBridge

#render

Methods included from ScopeOptions

#scope

Methods included from OptionsBase

#use_defaults

Methods included from LocationOptions

#assets_folder, #assets_output_folder, #coffee_folder, #css_output_folder, #js_output_folder, #layouts_folder, #output_folder, #styles_folder, #templates_folder

Methods included from SlimOptions

#slim_options

Methods included from FileHelpers

#copy_file, #create_file, #create_folder, #create_folder_for

Constructor Details

#initialize(scope = nil) ⇒ Scope

Returns a new instance of Scope.



5
6
7
# File 'lib/bobkit/scope.rb', line 5

def initialize(scope=nil)
  @scope = scope || {}
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *arguments, &block) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/bobkit/scope.rb', line 9

def method_missing(method_name, *arguments, &block)
  if @scope.respond_to?(:key?) and @scope.key?(method_name)
    @scope[method_name]
  elsif @scope.respond_to? method_name
    @scope.send method_name
  else
    super
  end
end

Instance Method Details

#respond_to?(method_name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
22
23
24
25
26
27
# File 'lib/bobkit/scope.rb', line 19

def respond_to?(method_name, include_private = false)
  if @scope.respond_to?(:key?) and @scope.key?(method_name)
    true
  elsif @scope.respond_to? method_name
    true
  else
    super
  end
end