Class: Basuco::Type

Inherits:
Object
  • Object
show all
Defined in:
lib/basuco/type.rb

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Type

initializes a resource using a json result



7
8
9
10
# File 'lib/basuco/type.rb', line 7

def initialize(data)
 # assert_kind_of 'data', data, Hash
  @data = data
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym) ⇒ Object

delegate to property_get



41
42
43
# File 'lib/basuco/type.rb', line 41

def method_missing sym
  property_get(sym.to_s)
end

Instance Method Details

#idObject

type id



20
21
22
# File 'lib/basuco/type.rb', line 20

def id
  @data["id"]
end

#inspectObject



36
37
38
# File 'lib/basuco/type.rb', line 36

def inspect
  result = "#<Type id=\"#{id}\" name=\"#{name || "nil"}\">"
end

#nameObject

type name



26
27
28
# File 'lib/basuco/type.rb', line 26

def name
  @data["name"]
end

#propertiesObject

access property info



14
15
16
# File 'lib/basuco/type.rb', line 14

def properties
  @properties ||= Basuco::Collection.new(@data["properties"].map { |property| Basuco::Property.new(property, self) })
end

#to_sObject



31
32
33
# File 'lib/basuco/type.rb', line 31

def to_s
  name || id || ""
end