Class: ParkingTicket::Configuration
- Inherits:
-
Object
- Object
- ParkingTicket::Configuration
- Defined in:
- lib/parking_ticket/configuration.rb
Class Method Summary collapse
Instance Method Summary collapse
- #completed? ⇒ Boolean
-
#initialize {|_self| ... } ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize {|_self| ... } ⇒ Configuration
Returns a new instance of Configuration.
20 21 22 23 |
# File 'lib/parking_ticket/configuration.rb', line 20 def initialize @attr_required = defined?(attr_required) ? attr_required : [] yield(self) end |
Class Method Details
.attr_required(*configuration_keys) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/parking_ticket/configuration.rb', line 6 def self.attr_required(*configuration_keys) define_method('attr_required') do configuration_keys end configuration_keys.each do |configuration_key| define_method configuration_key.to_s do instance_variable_get("@#{configuration_key}") end define_method "#{configuration_key}=" do |value| instance_variable_set("@#{configuration_key}", value) end end end |
Instance Method Details
#completed? ⇒ Boolean
25 26 27 |
# File 'lib/parking_ticket/configuration.rb', line 25 def completed? @attr_required.all? { |attribute_required| instance_variable_get("@#{attribute_required}") } end |