class GMO::PG::Payload::TypecastableValue

Attributes

value[RW]

Public Class Methods

from_hash(typecast_option) click to toggle source
Calls superclass method
# File lib/gmo-pg/http_resource/payload/typecast.rb, line 18
def self.from_hash(typecast_option)
  Class.new(self) do
    define_method :to_attribute do
      return super() unless typecast_option[:to_attribute].is_a?(Proc)
      typecast_option[:to_attribute].call(@value) rescue super()
    end

    define_method :to_payload do
      return super() unless typecast_option[:to_payload].is_a?(Proc)
      typecast_option[:to_payload].call(@value) rescue super()
    end
  end
end
new(value) click to toggle source
# File lib/gmo-pg/http_resource/payload/typecast.rb, line 32
def initialize(value)
  @value = value
end

Public Instance Methods

==(other) click to toggle source
# File lib/gmo-pg/http_resource/payload/typecast.rb, line 44
def ==(other)
  other_value = other.is_a?(self.class) ? other.to_payload : other
  to_payload == other_value
end
to_attribute() click to toggle source
# File lib/gmo-pg/http_resource/payload/typecast.rb, line 36
def to_attribute
  @value
end
to_payload() click to toggle source
# File lib/gmo-pg/http_resource/payload/typecast.rb, line 40
def to_payload
  @value.to_s
end