Module: CodeBox::CodeAttribute

Defined in:
lib/code-box/code_attribute.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Class Method Details

.[](*options) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/code-box/code_attribute.rb', line 6

def self.[](*options)
  instance_eval <<-RUBY_
    class << self
      def _code_box_i18n_model_segment
        "#{options.extract_options![:i18n_model_segment]}"
      end
    end
  RUBY_
  self
end

.included(base) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/code-box/code_attribute.rb', line 17

def self.included(base)
  unless (class << self; self; end).method_defined?(:_code_box_i18n_model_segment)
    instance_eval <<-RUBY_
      class << self
        def _code_box_i18n_model_segment
          nil
        end
      end
    RUBY_
  end

  base.extend(ClassMethods)

  instance_eval <<-RUBY_
    class << base
      def _code_box_i18n_model_segment
        return CodeBox.i18n_model_segment if "#{self._code_box_i18n_model_segment}".empty?
        "#{self._code_box_i18n_model_segment}"
      end
    end
  RUBY_
end