Module: Legato::ProfileMethods

Included in:
Management::Profile
Defined in:
lib/legato/profile_methods.rb

Class Method Summary collapse

Class Method Details

.add_profile_method(klass) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/legato/profile_methods.rb', line 3

def self.add_profile_method(klass)
  # demodulize leaves potential to redefine
  # these methods given different namespaces
  method_name = method_name_from_klass(klass)

  return unless method_name.length > 0

  class_eval <<-CODE
    def #{method_name}(opts={})
      #{klass}.results(self, opts)
    end
  CODE
end

.method_name_from_klass(klass) ⇒ Object



17
18
19
# File 'lib/legato/profile_methods.rb', line 17

def self.method_name_from_klass(klass)
  klass.name.to_s.gsub(":", "_").demodulize.underscore
end