Class: GenesisRuby::Api::Constants::States::State

Inherits:
Object
  • Object
show all
Defined in:
lib/genesis_ruby/api/constants/states/state.rb

Overview

Genesis Response Status definitions

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(state) ⇒ State

Returns a new instance of State.



19
20
21
# File 'lib/genesis_ruby/api/constants/states/state.rb', line 19

def initialize(state)
  @state = state
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(symbol, *args) ⇒ Object

States dynamic methods. Must be valid Genesis Transaction State Ex. new?, approved?



25
26
27
28
29
30
31
32
33
34
# File 'lib/genesis_ruby/api/constants/states/state.rb', line 25

def method_missing(symbol, *args)
  name = symbol.to_s.upcase

  super unless GenesisRuby::Api::Constants::States::State.handle_respond_to_states(name)

  name.chomp! '?'

  GenesisRuby::Api::Constants::States.valid?(name) &&
    state == GenesisRuby::Api::Constants::States.const_get(name)
end

Instance Attribute Details

#stateObject

Returns the value of attribute state.



17
18
19
# File 'lib/genesis_ruby/api/constants/states/state.rb', line 17

def state
  @state
end

Class Method Details

.handle_respond_to_states(symbol) ⇒ Object

Helper method for defining available dynamic methods



11
12
13
14
15
# File 'lib/genesis_ruby/api/constants/states/state.rb', line 11

def self.handle_respond_to_states(symbol)
  name = symbol.to_s.downcase

  name.slice!('?') == '?' && GenesisRuby::Api::Constants::States.valid?(name)
end

Instance Method Details

#respond_to_missing?(symbol, include_private = false) ⇒ Boolean

Respond to missing implementation

Returns:

  • (Boolean)


37
38
39
# File 'lib/genesis_ruby/api/constants/states/state.rb', line 37

def respond_to_missing?(symbol, include_private = false)
  GenesisRuby::Api::Constants::States::State.handle_respond_to_states(symbol) || super
end