Class: Convection::Model::Template::Resource::ScalarProperty

Inherits:
Property
  • Object
show all
Defined in:
lib/convection/model/template/resource.rb

Overview

A Scalar Property

Instance Attribute Summary

Attributes inherited from Property

#default, #equal_to, #immutable, #kind_of, #name, #property_name, #regex, #required, #transform

Instance Method Summary collapse

Methods inherited from Property

create, #initialize

Constructor Details

This class inherits a constructor from Convection::Model::Template::Resource::Property

Instance Method Details

#attach(resource) ⇒ Object



151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/convection/model/template/resource.rb', line 151

def attach(resource)
  definition = self ## Expose to resource instance closure

  resource.attach_method(definition.name) do |value = nil|
    return properties[definition.property_name].value if value.nil?
    properties[definition.property_name].set(value)
  end

  resource.attach_method("#{ definition.name }=") do |value|
    properties[definition.property_name].set(value)
  end
end

#instance(resource) ⇒ Object



164
165
166
# File 'lib/convection/model/template/resource.rb', line 164

def instance(resource)
  ScalarPropertyInstance.new(resource, self)
end