Module: XClarityClient::Endpoints::BuildableResourceMixin
- Included in:
- XclarityEndpoint
- Defined in:
- lib/xclarity_client/endpoints/buildable_resource_mixin.rb
Overview
A Buildable Resource can build itself from some formats of data (ex: Hashes) and also can transform itself in other formats of data.
Instance Method Summary collapse
-
#build_resource!(attributes) ⇒ Object
Builds the resource from a Hash.
-
#to_hash ⇒ Hash
Converts the resource into a Hash.
Instance Method Details
#build_resource!(attributes) ⇒ Object
Builds the resource from a Hash.
15 16 17 |
# File 'lib/xclarity_client/endpoints/buildable_resource_mixin.rb', line 15 def build_resource!(attributes) attributes.each { |key, value| set_attr(key, value) } end |
#to_hash ⇒ Hash
Converts the resource into a Hash.
24 25 26 27 28 |
# File 'lib/xclarity_client/endpoints/buildable_resource_mixin.rb', line 24 def to_hash hash = {} instance_variables.each {|var| hash[var.to_s.delete("@")] = instance_variable_get(var) } hash end |