Class: Traco::Attributes

Inherits:
Module
  • Object
show all
Defined in:
lib/traco/attributes.rb

Instance Method Summary collapse

Constructor Details

#initialize(*attributes) ⇒ Attributes

Returns a new instance of Attributes.



3
4
5
6
7
8
9
10
11
12
# File 'lib/traco/attributes.rb', line 3

def initialize(*attributes)
  @options = attributes.extract_options!
  @attributes = attributes.map(&:to_sym)

  attributes.each do |attribute|
    define_reader(attribute)
    define_writer(attribute)
    define_query(attribute)
  end
end

Instance Method Details

#included(base) ⇒ Object



14
15
16
17
18
19
# File 'lib/traco/attributes.rb', line 14

def included(base)
  self.class.ensure_translatable_attributes(base)
  base.translatable_attributes |= @attributes

  base.extend ClassMethods
end