Module: Olelo::Attributes

Included in:
Page
Defined in:
lib/olelo/attributes.rb

Overview

Include module to add attribute editor to a class.

Defined Under Namespace

Modules: ClassMethods Classes: Attribute, AttributeDSL, AttributeGroup

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



4
5
6
# File 'lib/olelo/attributes.rb', line 4

def self.included(base)
  base.extend(ClassMethods)
end

Instance Method Details

#attribute_editorString

Generate attribute editor form

Parameters:

  • default_values (Hash)

    to use for the form

Returns:

  • (String)

    Generated html form



281
282
283
# File 'lib/olelo/attributes.rb', line 281

def attribute_editor
  self.class.attribute_group.build_form(attributes).html_safe
end

#update_attributes(params) ⇒ Hash

Parse attributes from params hash

Parameters:

  • params (Hash)

    submitted params hash

Returns:

  • (Hash)

    Attributes



271
272
273
# File 'lib/olelo/attributes.rb', line 271

def update_attributes(params)
  self.attributes = self.class.attribute_group.parse(params)
end