Class: RubyFly::RC::Target

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_fly/rc.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parameters) ⇒ Target



72
73
74
75
76
77
# File 'lib/ruby_fly/rc.rb', line 72

def initialize(parameters)
  @name = parameters[:name]
  @api = parameters[:api]
  @team = parameters[:team]
  @token = parameters[:token]
end

Instance Attribute Details

#apiObject

Returns the value of attribute api.



58
59
60
# File 'lib/ruby_fly/rc.rb', line 58

def api
  @api
end

#nameObject (readonly)

Returns the value of attribute name.



58
59
60
# File 'lib/ruby_fly/rc.rb', line 58

def name
  @name
end

#teamObject

Returns the value of attribute team.



58
59
60
# File 'lib/ruby_fly/rc.rb', line 58

def team
  @team
end

#tokenObject

Returns the value of attribute token.



58
59
60
# File 'lib/ruby_fly/rc.rb', line 58

def token
  @token
end

Class Method Details

.clone(target, overrides = {}) ⇒ Object



61
62
63
64
65
66
67
68
69
70
# File 'lib/ruby_fly/rc.rb', line 61

def self.clone(target, overrides = {})
  if target.nil?
    return target
  end
  Target.new(
      name: overrides[:name] || target.name,
      api: overrides[:api] || target.api,
      team: overrides[:team] || target.team,
      token: overrides[:token] || target.token)
end

Instance Method Details

#==(other) ⇒ Object



102
103
104
# File 'lib/ruby_fly/rc.rb', line 102

def ==(other)
  other.class == self.class && other.state == state
end

#bearer_tokenObject



86
87
88
89
90
# File 'lib/ruby_fly/rc.rb', line 86

def bearer_token
  @token[:type] == 'bearer' ?
      @token[:value] :
      nil
end

#bearer_token=(value) ⇒ Object



79
80
81
82
83
84
# File 'lib/ruby_fly/rc.rb', line 79

def bearer_token=(value)
  @token = {
      type: 'bearer',
      value: value
  }
end

#encode_with(coder) ⇒ Object



92
93
94
95
96
97
98
99
100
# File 'lib/ruby_fly/rc.rb', line 92

def encode_with(coder)
  coder.represent_map(
      nil,
      RubyFly::RC::Conversions.stringify_keys({
          api: @api,
          team: @team.to_s,
          token: @token
      }))
end

#eql?(other) ⇒ Boolean



106
107
108
# File 'lib/ruby_fly/rc.rb', line 106

def eql?(other)
  self == other
end

#hashObject



110
111
112
# File 'lib/ruby_fly/rc.rb', line 110

def hash
  state.hash
end