Class: Refinery::Widgets::WidgetType
- Inherits:
-
Object
- Object
- Refinery::Widgets::WidgetType
- Defined in:
- lib/refinery/widgets/widget_type.rb
Instance Attribute Summary collapse
-
#admin_partial ⇒ Object
readonly
Returns the value of attribute admin_partial.
-
#admin_preview_partial ⇒ Object
readonly
Returns the value of attribute admin_preview_partial.
-
#association_name ⇒ Object
readonly
Returns the value of attribute association_name.
-
#attribute_param ⇒ Object
readonly
Returns the value of attribute attribute_param.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#front_partial ⇒ Object
readonly
Returns the value of attribute front_partial.
-
#html_id ⇒ Object
readonly
Returns the value of attribute html_id.
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
-
#klass_as_string ⇒ Object
readonly
Returns the value of attribute klass_as_string.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(class_as_string) ⇒ WidgetType
constructor
A new instance of WidgetType.
Constructor Details
#initialize(class_as_string) ⇒ WidgetType
Returns a new instance of WidgetType.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/refinery/widgets/widget_type.rb', line 9 def initialize(class_as_string) if class_as_string.is_a?(Hash) attributes = class_as_string.dup class_as_string = attributes[:name] description = attributes[:description] end @klass_as_string = class_as_string @klass = class_as_string.constantize @html_id = class_as_string.split('::').last.underscore @association_name = @html_id @attribute_param = "#{@association_name}_attributes" @admin_partial = @html_id @admin_preview_partial = "#{@html_id}_preview" @front_partial = @html_id @name = @html_id.humanize @description = description || '' end |
Instance Attribute Details
#admin_partial ⇒ Object (readonly)
Returns the value of attribute admin_partial.
5 6 7 |
# File 'lib/refinery/widgets/widget_type.rb', line 5 def admin_partial @admin_partial end |
#admin_preview_partial ⇒ Object (readonly)
Returns the value of attribute admin_preview_partial.
5 6 7 |
# File 'lib/refinery/widgets/widget_type.rb', line 5 def admin_preview_partial @admin_preview_partial end |
#association_name ⇒ Object (readonly)
Returns the value of attribute association_name.
5 6 7 |
# File 'lib/refinery/widgets/widget_type.rb', line 5 def association_name @association_name end |
#attribute_param ⇒ Object (readonly)
Returns the value of attribute attribute_param.
5 6 7 |
# File 'lib/refinery/widgets/widget_type.rb', line 5 def attribute_param @attribute_param end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
5 6 7 |
# File 'lib/refinery/widgets/widget_type.rb', line 5 def description @description end |
#front_partial ⇒ Object (readonly)
Returns the value of attribute front_partial.
5 6 7 |
# File 'lib/refinery/widgets/widget_type.rb', line 5 def front_partial @front_partial end |
#html_id ⇒ Object (readonly)
Returns the value of attribute html_id.
5 6 7 |
# File 'lib/refinery/widgets/widget_type.rb', line 5 def html_id @html_id end |
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
5 6 7 |
# File 'lib/refinery/widgets/widget_type.rb', line 5 def klass @klass end |
#klass_as_string ⇒ Object (readonly)
Returns the value of attribute klass_as_string.
5 6 7 |
# File 'lib/refinery/widgets/widget_type.rb', line 5 def klass_as_string @klass_as_string end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/refinery/widgets/widget_type.rb', line 5 def name @name end |
Class Method Details
.all ⇒ Object
27 28 29 30 |
# File 'lib/refinery/widgets/widget_type.rb', line 27 def self.all Refinery::Widgets.config[:base_widgets].collect{|w| self.new(w) } + Refinery::Widgets.config[:additional_widgets].collect{|w| self.new(w) } end |
.find(class_as_string) ⇒ Object
32 33 34 |
# File 'lib/refinery/widgets/widget_type.rb', line 32 def self.find(class_as_string) self.new(class_as_string) end |