Class: Cassandra::Mocks::Statement::Token

Inherits:
Struct
  • Object
show all
Defined in:
lib/cassandra_mocks/statement/token.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/cassandra_mocks/statement/token.rb', line 20

def method_missing(method, *args)
  if method_inquiry?(method)
    method[/[^\?]+/].to_sym == type
  else
    super
  end
end

Instance Attribute Details

#typeObject

Returns the value of attribute type

Returns:

  • (Object)

    the current value of type



4
5
6
# File 'lib/cassandra_mocks/statement/token.rb', line 4

def type
  @type
end

#valueObject

Returns the value of attribute value

Returns:

  • (Object)

    the current value of value



4
5
6
# File 'lib/cassandra_mocks/statement/token.rb', line 4

def value
  @value
end

Instance Method Details

#normalized_valueObject



5
6
7
8
9
10
11
12
13
14
# File 'lib/cassandra_mocks/statement/token.rb', line 5

def normalized_value
  case type
    when :int
      value.to_i
    when :float
      value.to_f
    else
      value
  end
end

#respond_to?(method) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/cassandra_mocks/statement/token.rb', line 16

def respond_to?(method)
  method_inquiry?(method) || super
end