Module: ClassWithAttributes::ClassMethods
- Defined in:
- lib/check_mobi/shared/class_with_attributes.rb
Instance Method Summary collapse
- #attribute(name, options = {}) ⇒ Object
- #attributes(*vars) ⇒ Object
- #readonly_attribute(name, options = {}) ⇒ Object
- #readonly_attributes(*vars) ⇒ Object
Instance Method Details
#attribute(name, options = {}) ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/check_mobi/shared/class_with_attributes.rb', line 30 def attribute(name, ={}) @attributes ||= [] @attributes << ({name: name, default: [:default]}) send :include, InstanceMethods unless included_modules.include?(InstanceMethods) attr_accessor name end |
#attributes(*vars) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/check_mobi/shared/class_with_attributes.rb', line 8 def attributes(*vars) @attributes ||= [] vars.uniq.each do |var| @attributes << {name: var, default: nil} end send :include, InstanceMethods unless included_modules.include?(InstanceMethods) attr_accessor *vars end |
#readonly_attribute(name, options = {}) ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/check_mobi/shared/class_with_attributes.rb', line 39 def readonly_attribute(name, ={}) @attributes ||= [] @attributes << ({name: name, default: [:default]}) send :include, InstanceMethods unless included_modules.include?(InstanceMethods) attr_reader name end |
#readonly_attributes(*vars) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/check_mobi/shared/class_with_attributes.rb', line 19 def readonly_attributes(*vars) @attributes ||= [] vars.uniq.each do |var| @attributes << {name: var, default: nil} end send :include, InstanceMethods unless included_modules.include?(InstanceMethods) attr_reader *vars end |