Class: MaskableAttribute::Formatting::Format

Inherits:
Object
  • Object
show all
Defined in:
lib/maskable_attribute/formatting.rb

Instance Method Summary collapse

Constructor Details

#initialize(method = nil) ⇒ Format

Returns a new instance of Format.



56
57
58
# File 'lib/maskable_attribute/formatting.rb', line 56

def initialize(method=nil)
  @method = method
end

Instance Method Details

#apply(input) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/maskable_attribute/formatting.rb', line 60

def apply(input)
  begin
    if @method.is_a? Symbol
      input.send(@method)
    elsif @method.is_a? Proc
      @method.call input
    else
      input
    end
  rescue
    nil
  end
end