Class: Wakari::Bundle
- Inherits:
-
Object
- Object
- Wakari::Bundle
- Defined in:
- lib/wakari/bundle.rb
Instance Attribute Summary collapse
-
#content_class ⇒ Object
readonly
Returns the value of attribute content_class.
-
#meta_class ⇒ Object
readonly
Returns the value of attribute meta_class.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#proxy_class ⇒ Object
readonly
Returns the value of attribute proxy_class.
-
#translation_class ⇒ Object
readonly
Returns the value of attribute translation_class.
Instance Method Summary collapse
- #full_translation_name ⇒ Object
-
#initialize(content_class, *args) ⇒ Bundle
constructor
A new instance of Bundle.
- #name ⇒ Object
- #prepare! ⇒ Object
- #translation_name ⇒ Object
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. end |
Instance Attribute Details
#content_class ⇒ Object (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_class ⇒ Object (readonly)
Returns the value of attribute meta_class.
10 11 12 |
# File 'lib/wakari/bundle.rb', line 10 def @meta_class end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
10 11 12 |
# File 'lib/wakari/bundle.rb', line 10 def @options end |
#proxy_class ⇒ Object (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_class ⇒ Object (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_name ⇒ Object
26 27 28 |
# File 'lib/wakari/bundle.rb', line 26 def full_translation_name [content_class.model_name.param_key, translation_name].join("_") end |
#name ⇒ Object
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! .send(:include, Wakari::Meta::Model) .send(:acts_as_meta_class, *) 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_name ⇒ Object
22 23 24 |
# File 'lib/wakari/bundle.rb', line 22 def translation_name name||"translation" end |