Module: CanTango::Permit::Attribute::ClassMethods
- Included in:
- CanTango::Permit::Attribute
- Defined in:
- lib/cantango/permit/attribute.rb
Instance Method Summary collapse
- #attribute(name = nil) ⇒ Object (also: #type, #hash_key)
- #attribute_name(clazz = nil) ⇒ Object
- #inherited(base_clazz) ⇒ Object
Instance Method Details
#attribute(name = nil) ⇒ Object Also known as: type, hash_key
4 5 6 7 8 |
# File 'lib/cantango/permit/attribute.rb', line 4 def attribute name = nil @attribute ||= self.name.demodulize.gsub(/(.*)Permit/, '\1').underscore.to_sym return @attribute unless name @attribute = name end |
#attribute_name(clazz = nil) ⇒ Object
18 19 20 21 |
# File 'lib/cantango/permit/attribute.rb', line 18 def attribute_name clazz = nil clazz ||= self clazz.name.demodulize.gsub(/(.*)(#{attribute.to_s.camelize}Permit)/, '\1').underscore.to_sym end |
#inherited(base_clazz) ⇒ Object
13 14 15 16 |
# File 'lib/cantango/permit/attribute.rb', line 13 def inherited(base_clazz) register_type base_clazz # register base_clazz, :name => attribute_name(base_clazz) end |