Class: Wakari::Bundle

Inherits:
Object
  • Object
show all
Defined in:
lib/wakari/bundle.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content_class, *args) ⇒ Bundle

Returns a new instance of Bundle.



12
13
14
15
16
# File 'lib/wakari/bundle.rb', line 12

def initialize(content_class, *args)
  @content_class = content_class
  @name = args.first
  @options = args.extract_options!
end

Instance Attribute Details

#content_classObject (readonly)

Returns the value of attribute content_class.



10
11
12
# File 'lib/wakari/bundle.rb', line 10

def content_class
  @content_class
end

#meta_classObject (readonly)

Returns the value of attribute meta_class.



10
11
12
# File 'lib/wakari/bundle.rb', line 10

def meta_class
  @meta_class
end

#optionsObject (readonly)

Returns the value of attribute options.



10
11
12
# File 'lib/wakari/bundle.rb', line 10

def options
  @options
end

#proxy_classObject (readonly)

Returns the value of attribute proxy_class.



10
11
12
# File 'lib/wakari/bundle.rb', line 10

def proxy_class
  @proxy_class
end

#translation_classObject (readonly)

Returns the value of attribute translation_class.



10
11
12
# File 'lib/wakari/bundle.rb', line 10

def translation_class
  @translation_class
end

Instance Method Details

#full_translation_nameObject



26
27
28
# File 'lib/wakari/bundle.rb', line 26

def full_translation_name
  [content_class.model_name.param_key, translation_name].join("_")
end

#nameObject



18
19
20
# File 'lib/wakari/bundle.rb', line 18

def name
  @name.to_s.underscore if @name
end

#prepare!Object



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/wakari/bundle.rb', line 58

def prepare!
  meta_class.send(:include, Wakari::Meta::Model)
  meta_class.send(:acts_as_meta_class, *meta_class_args)
  
  translation_class.send(:include, Wakari::Translation::Model)
  translation_class.send(:acts_as_translation_class, *translation_class_args)
  
  content_class.send(:include, Wakari::Content::Model)
  content_class.send(:acts_as_content_class, *content_class_args)
        
  if proxy_class
    proxy_class.send(:include, Wakari::Proxy::Model)
    proxy_class.send(:acts_as_proxy, *proxy_class_args)
    content_class.class_eval <<-EOV
      attr_accessible :#{name}
      
      def #{name}
        #{proxy_class}.new(self)
      end
      def #{name}=(*args)
        #{proxy_class}.new(self).write(*args)
      end
    EOV
   else
    content_class.send(:include, Wakari::Proxy::Model) unless content_class < Wakari::Proxy::Model
    content_class.send(:acts_as_proxy, *proxy_class_args)
  end
end

#translation_nameObject



22
23
24
# File 'lib/wakari/bundle.rb', line 22

def translation_name
  name||"translation"
end