Module: Puffer

Defined in:
lib/puffer/controller/config.rb,
lib/puffer.rb,
lib/puffer/field.rb,
lib/puffer/engine.rb,
lib/puffer/filters.rb,
lib/puffer/version.rb,
lib/puffer/resource.rb,
lib/puffer/component.rb,
lib/puffer/field_set.rb,
lib/puffer/resource/node.rb,
lib/puffer/resource/tree.rb,
lib/puffer/controller/dsl.rb,
lib/puffer/controller/auth.rb,
lib/puffer/extensions/core.rb,
lib/puffer/orm_adapter/base.rb,
lib/puffer/resource/routing.rb,
lib/puffer/controller/mutate.rb,
lib/puffer/extensions/engine.rb,
lib/puffer/controller/actions.rb,
lib/puffer/extensions/mapper31.rb,
lib/puffer/extensions/mapper32.rb,
lib/puffer/orm_adapter/mongoid.rb,
lib/puffer/extensions/controller.rb,
lib/puffer/helpers/puffer_helper.rb,
lib/puffer/helpers/component_helper.rb,
lib/puffer/backends/controllers/base.rb,
lib/puffer/backends/models/user/base.rb,
lib/puffer/orm_adapter/active_record.rb,
lib/puffer/helpers/puffer_tree_helper.rb,
lib/puffer/backends/models/user/mongoid.rb,
lib/puffer/backends/controllers/grid_base.rb,
lib/puffer/backends/controllers/tree_base.rb,
lib/puffer/extensions/directive_processor.rb,
lib/puffer/backends/models/user/active_record.rb,
lib/puffer/backends/controllers/puffer_users_base.rb

Overview

Every puffer controller can be configured Something like:

setup do
  group :posting
  model_name 'article'
end

Defined Under Namespace

Modules: Component, Controller, Extensions, Helpers, OrmAdapter, Sessions, User Classes: Base, ComponentGenerator, ComponentMissing, ControllerGenerator, DashboardBase, Engine, Field, FieldSet, Filters, GridBase, PufferError, PufferUsersBase, Resource, TreeBase

Constant Summary collapse

TRUE_VALUES =
[true, 1, '1', 't', 'T', 'true', 'TRUE'].to_set
FALSE_VALUES =
[false, 0, '0', 'f', 'F', 'false', 'FALSE'].to_set
VERSION =
"0.1.1"

Class Method Summary collapse

Class Method Details

.append_custom_field_type(custom_type, &block) ⇒ Object


109
110
111
# File 'lib/puffer.rb', line 109

def self.append_custom_field_type custom_type, &block
  _field_type_customs.push [custom_type, block]
end

.component_for(field) ⇒ Object


78
79
80
81
82
83
84
# File 'lib/puffer.rb', line 78

def self.component_for field
  type = field
  type = field.type if field.respond_to? :type
  (_component_mappings[type.to_sym] || "#{type}_component").to_s.camelize.constantize
rescue NameError
  raise ComponentMissing, "Missing `#{type}` component for `#{field}` field. Please use Puffer.map_component binding or specify field type manually"
end

.field_type_for(field) ⇒ Object


113
114
115
116
117
118
119
120
121
# File 'lib/puffer.rb', line 113

def self.field_type_for field
  custom_type = swallow_nil{_field_type_customs.detect {|(type, block)| block.call(field) }.first}
  case custom_type
  when Proc then
    custom_type.call(field)
  else
    custom_type
  end
end

.map_component(*args) ⇒ Object

Maps field.type to component class

ex:

Puffer.map_component :ckeditor, :rich, :text, :to => CkeditorComponent

this declaration maps even text fields to use CkeditorComponent for rendering


73
74
75
76
# File 'lib/puffer.rb', line 73

def self.map_component *args
  to = args.extract_options![:to]
  args.each { |type| _component_mappings[type.to_sym] = to }
end

.prepend_custom_field_type(custom_type, &block) ⇒ Object

Appends or prepends custom type.

ex:

Puffer.append_custom_field_type :paperclip do |field|
  field.model.respond_to?(:attachment_definitions)
    && field.model.attachment_definitions.key?(:field.field_name.to_sym)
end

105
106
107
# File 'lib/puffer.rb', line 105

def self.prepend_custom_field_type custom_type, &block
  _field_type_customs.shift [custom_type, block]
end