Class: DataMapper::Reflection::Builders::Source::Property
- Inherits:
-
Object
- Object
- DataMapper::Reflection::Builders::Source::Property
show all
- Includes:
- OptionBuilder
- Defined in:
- lib/dm-reflection/builders/source_builder.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#backend_options, #rest_options
Instance Attribute Details
#backend ⇒ Object
Returns the value of attribute backend.
157
158
159
|
# File 'lib/dm-reflection/builders/source_builder.rb', line 157
def backend
@backend
end
|
Class Method Details
.for(backend) ⇒ Object
159
160
161
|
# File 'lib/dm-reflection/builders/source_builder.rb', line 159
def self.for(backend)
new(backend)
end
|
Instance Method Details
#irrelevant_options ⇒ Object
195
196
197
|
# File 'lib/dm-reflection/builders/source_builder.rb', line 195
def irrelevant_options
[]
end
|
#name ⇒ Object
167
168
169
|
# File 'lib/dm-reflection/builders/source_builder.rb', line 167
def name
backend.name
end
|
#option_priorities ⇒ Object
180
181
182
|
# File 'lib/dm-reflection/builders/source_builder.rb', line 180
def option_priorities
[ :key, :required, :unique, :unique_index ]
end
|
#options ⇒ Object
176
177
178
|
# File 'lib/dm-reflection/builders/source_builder.rb', line 176
def options
backend.type == DataMapper::Types::Serial ? '' : super
end
|
#prioritized_options ⇒ Object
184
185
186
187
188
189
190
191
192
193
|
# File 'lib/dm-reflection/builders/source_builder.rb', line 184
def prioritized_options
option_priorities.inject([]) do |memo, name|
if name == :required
memo << [ name, backend_options[name] ] if backend_options[name] && !backend_options[:key]
else
memo << [ name, backend_options[name] ] if backend_options[name]
end
memo
end
end
|
#to_ruby ⇒ Object
163
164
165
|
# File 'lib/dm-reflection/builders/source_builder.rb', line 163
def to_ruby
"property :#{name}, #{type}#{options}"
end
|
#type ⇒ Object
171
172
173
|
# File 'lib/dm-reflection/builders/source_builder.rb', line 171
def type
ActiveSupport::Inflector.demodulize(backend.type)
end
|