Class: Walruz::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/walruz/config.rb

Instance Method Summary collapse

Instance Method Details

#actors=(actors) ⇒ Object

Given a list of classes, it will include the Actor module in each of them.

system

Parameters:

  • actors (Class)

    The list of classes that will be Actors in the



10
11
12
13
14
# File 'lib/walruz/config.rb', line 10

def actors=(actors)
  Array(actors).each do |actor|
    actor.send(:include, Actor)
  end
end

#enable_array_extensionObject

Will include the Walruz:CoreExt:Array module to the Array class



52
53
54
55
56
57
# File 'lib/walruz/config.rb', line 52

def enable_array_extension
  require File.expand_path(
      File.join(File.dirname(__FILE__), 'core_ext', 'array')
  )
  safe_include(Array, Walruz::CoreExt::Array)
end

#enable_will_paginate_extension(options = {}) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/walruz/config.rb', line 27

def enable_will_paginate_extension(options = {})
  options = { :include_rails => false }.merge!(options)
  gem 'will_paginate'
  require File.expand_path(
    File.join(File.dirname(__FILE__),  'more', 'pagination')
  )

  safe_include(WillPaginate::Collection,
               Walruz::More::Pagination::WillPaginateCollection)
  safe_include(Array, Walruz::More::Pagination::Base)

  if options[:include_rails]
    raise LoadError.new("You ask to enable Walruz extensions on \
ActiveRecord::Base, but it was not found. Maybe you should require \
'active_record' first?") unless defined?("ActiveRecord::Base")
    safe_include(::ActiveRecord::Base, Walruz::More::Pagination::Base)
  end
rescue Gem::LoadError
  raise LoadError.new("You ask to enable Walruz extensions on \
WillPaginate, but it was not found, Maybe you should \
require 'will_paginate' first")
end

#subjects=(subjects) ⇒ Object

Given a list of classes, it will include the Subject module in each of them.

system

Parameters:

  • subjects (Class)

    The list of classes that will be Subject in the



21
22
23
24
25
# File 'lib/walruz/config.rb', line 21

def subjects=(subjects)
  Array(subjects).each do |subject|
    subject.send(:include, Subject)
  end
end