Class: Rulix::Mutators::Default

Inherits:
Object
  • Object
show all
Defined in:
lib/rulix/mutators/default.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(default_val) ⇒ Default

Returns a new instance of Default.



6
7
8
# File 'lib/rulix/mutators/default.rb', line 6

def initialize default_val
  self.default_val = default_val
end

Instance Attribute Details

#default_valObject

Returns the value of attribute default_val.



4
5
6
# File 'lib/rulix/mutators/default.rb', line 4

def default_val
  @default_val
end

Instance Method Details

#call(string) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/rulix/mutators/default.rb', line 14

def call string
  if string
    string
  else
    default_val
  end
end

#to_procObject



10
11
12
# File 'lib/rulix/mutators/default.rb', line 10

def to_proc
  method(:call)
end