Class: Basuco::Type
- Inherits:
-
Object
- Object
- Basuco::Type
- Defined in:
- lib/basuco/type.rb
Instance Method Summary collapse
-
#id ⇒ Object
type id.
-
#initialize(data) ⇒ Type
constructor
initializes a resource using a json result.
- #inspect ⇒ Object
-
#method_missing(sym) ⇒ Object
delegate to property_get.
-
#name ⇒ Object
type name.
-
#properties ⇒ Object
access property info.
- #to_s ⇒ Object
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
#id ⇒ Object
type id
20 21 22 |
# File 'lib/basuco/type.rb', line 20 def id @data["id"] end |
#inspect ⇒ Object
36 37 38 |
# File 'lib/basuco/type.rb', line 36 def inspect result = "#<Type id=\"#{id}\" name=\"#{name || "nil"}\">" end |
#name ⇒ Object
type name
26 27 28 |
# File 'lib/basuco/type.rb', line 26 def name @data["name"] end |
#properties ⇒ Object
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_s ⇒ Object
31 32 33 |
# File 'lib/basuco/type.rb', line 31 def to_s name || id || "" end |