Class: HaveAPI::GoClient::Parameters::Base

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/haveapi/go_client/parameters/base.rb

Direct Known Subclasses

GlobalMetaIncludes, Resource, Typed

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Utils

#camelize

Constructor Details

#initialize(io, name, desc) ⇒ Base

Returns a new instance of Base.



45
46
47
48
49
50
51
# File 'lib/haveapi/go_client/parameters/base.rb', line 45

def initialize(io, name, desc)
  @io = io
  @name = name
  @type = desc[:type]
  @desc = desc
  @go_name = camelize(name)
end

Instance Attribute Details

#go_in_typeString (readonly)

Go type for action input

Returns:

  • (String)


39
40
41
# File 'lib/haveapi/go_client/parameters/base.rb', line 39

def go_in_type
  @go_in_type
end

#go_nameString (readonly)

Parameter name in Go

Returns:

  • (String)


35
36
37
# File 'lib/haveapi/go_client/parameters/base.rb', line 35

def go_name
  @go_name
end

#go_out_typeString (readonly)

Go type for action output

Returns:

  • (String)


43
44
45
# File 'lib/haveapi/go_client/parameters/base.rb', line 43

def go_out_type
  @go_out_type
end

#ioInputOutput (readonly)

Returns:



23
24
25
# File 'lib/haveapi/go_client/parameters/base.rb', line 23

def io
  @io
end

#nameString (readonly)

Parameter name in the API

Returns:

  • (String)


27
28
29
# File 'lib/haveapi/go_client/parameters/base.rb', line 27

def name
  @name
end

#typeString (readonly)

HaveAPI data type

Returns:

  • (String)


31
32
33
# File 'lib/haveapi/go_client/parameters/base.rb', line 31

def type
  @type
end

Class Method Details

.handle {|role, direction, name, desc| ... } ⇒ Object

Register the parameter handler

The block is called whenever a new parameter is to be instantiated. If this class supports the parameter, the block returns true, else false. The first class to return true is used.

Yield Parameters:

  • role (Symbol)
  • direction (Symbol)
  • name (String)
  • desc (Hash)


18
19
20
# File 'lib/haveapi/go_client/parameters/base.rb', line 18

def self.handle(&block)
  Parameter.register(self, block)
end

Instance Method Details

#<=>(other) ⇒ Object



62
63
64
# File 'lib/haveapi/go_client/parameters/base.rb', line 62

def <=>(other)
  go_name <=> other
end

#nillable?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/haveapi/go_client/parameters/base.rb', line 58

def nillable?
  false
end

#resolveObject



53
54
55
56
# File 'lib/haveapi/go_client/parameters/base.rb', line 53

def resolve
  do_resolve
  @desc = nil
end