Class: Inch::API::Options::Base
- Inherits:
-
Object
- Object
- Inch::API::Options::Base
- Defined in:
- lib/inch/api/options/base.rb
Class Method Summary collapse
-
.attribute(name, default = nil) ⇒ void
Creates an attribute with an optional default value.
- .attribute_names ⇒ Object
Instance Method Summary collapse
-
#initialize(options_or_hash) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(options_or_hash) ⇒ Base
Returns a new instance of Base.
26 27 28 29 30 |
# File 'lib/inch/api/options/base.rb', line 26 def initialize() self.class.attribute_names.each do |name| read , name end end |
Class Method Details
.attribute(name, default = nil) ⇒ void
This method returns an undefined value.
Creates an attribute with an optional default value
11 12 13 14 15 16 17 18 |
# File 'lib/inch/api/options/base.rb', line 11 def attribute(name, default = nil) define_method(name) do instance_variable_get("@#{name}") || default end @attributes ||= {} @attributes[to_s] ||= [] @attributes[to_s] << name end |
.attribute_names ⇒ Object
20 21 22 23 |
# File 'lib/inch/api/options/base.rb', line 20 def attribute_names @attributes ||= {} @attributes[to_s] ||= [] end |