Class: Rohbau::Entity
- Inherits:
-
Object
- Object
- Rohbau::Entity
- Defined in:
- lib/rohbau/entity.rb
Class Attribute Summary collapse
-
.__attributes__ ⇒ Object
Returns the value of attribute __attributes__.
Class Method Summary collapse
Instance Method Summary collapse
Class Attribute Details
.__attributes__ ⇒ Object
Returns the value of attribute __attributes__.
3 4 5 |
# File 'lib/rohbau/entity.rb', line 3 def __attributes__ @__attributes__ end |
Class Method Details
.attributes(*attributes) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/rohbau/entity.rb', line 4 def self.attributes(*attributes) @__attributes__ ||= [] @__attributes__ += attributes predicate_attributes = attributes.select do |attr| attr =~ /\?$/ end regular_attributes = attributes - predicate_attributes predicate_attributes.each do |attribute| attribute_without_predicate = attribute.to_s.gsub(/\?$/, '') attr_accessor attribute_without_predicate define_method attribute do || !!instance_variable_get(:"@#{attribute_without_predicate}") end end attr_accessor(*regular_attributes) end |
Instance Method Details
#==(other) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/rohbau/entity.rb', line 26 def ==(other) other && __attributes__.all? do |attr| other.respond_to?(attr) && self.public_send(attr) == other.public_send(attr) end end |