Module: Kanrisuru::OsPackage::Define

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



6
7
8
9
# File 'lib/kanrisuru/os_package/define.rb', line 6

def self.extended(base)
  base.instance_variable_set(:@os_method_properties, {})
  base.instance_variable_set(:@os_methods, Set.new)
end

Instance Method Details

#os_define(os_name, method_name, options = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/kanrisuru/os_package/define.rb', line 11

def os_define(os_name, method_name, options = {})
  unique_method_name = options[:alias] || method_name

  @os_methods.add(method_name)

  if @os_method_properties.key?(unique_method_name)
    params = {
      os_name: os_name.to_s,
      method_name: method_name,
      options: options
    }

    @os_method_properties[unique_method_name].prepend(params)
  else
    @os_method_properties[unique_method_name] = [{
      os_name: os_name.to_s,
      method_name: method_name,
      options: options
    }]
  end
end