Class: ActiveBlocks::Decorator

Inherits:
Object
  • Object
show all
Includes:
Schema, Setup
Defined in:
lib/active_blocks/decorator.rb,
lib/active_blocks/decorator/setup.rb,
lib/active_blocks/decorator/schema.rb,
lib/active_blocks/decorator/attributes/definition.rb,
lib/active_blocks/decorator/attributes/definitions_each.rb

Direct Known Subclasses

Form

Defined Under Namespace

Modules: Attributes, Schema, Setup

Instance Attribute Summary

Attributes included from Setup

#attributes, #model

Class Method Summary collapse

Methods included from Schema

included, #schema

Methods included from Setup

#initialize, #setup_attribute, #setup_attributes

Class Method Details

.attribute(name, options = {}, &block) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/active_blocks/decorator.rb', line 11

def attribute(name, options={}, &block)

  definitions[name.to_sym] = build_definition(name, options)

  mod = Module.new do
    define_method(name)       { instance_variable_get("@#{name}") }
    define_method("#{name}=") { |value| instance_variable_set("@#{name}", value) }
  end
  include mod

end