Class: Backend::KujakuHelper::Kujaku::Feather

Inherits:
Object
  • Object
show all
Defined in:
app/helpers/backend/kujaku_helper.rb

Overview

Hane means “feather”. It designs a criterion

Direct Known Subclasses

ChoiceFeather, MultiChoiceFeather, TextFeather

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(kujaku, uid, *args, &block) ⇒ Feather


58
59
60
61
62
63
64
65
# File 'app/helpers/backend/kujaku_helper.rb', line 58

def initialize(kujaku, uid, *args, &block)
  @kujaku = kujaku
  @uid = uid
  @template = kujaku.template
  @options = args.extract_options!
  @block = block if block_given?
  configure(*args)
end

Instance Attribute Details

#uidObject (readonly)

Returns the value of attribute uid


56
57
58
# File 'app/helpers/backend/kujaku_helper.rb', line 56

def uid
  @uid
end

Class Method Details

.feather_nameObject


51
52
53
# File 'app/helpers/backend/kujaku_helper.rb', line 51

def feather_name
  @feather_name ||= name.gsub(/Feather$/, '').underscore.split('/').last.to_sym
end

.inherited(subclass) ⇒ Object


42
43
44
45
46
47
48
49
# File 'app/helpers/backend/kujaku_helper.rb', line 42

def inherited(subclass)
  class_name = subclass.name
  raise 'Invalid feather name' unless class_name =~ /Feather$/
  feather_name = class_name.gsub(/Feather$/, '').underscore.split('/').last.to_sym
  Kujaku.send(:define_method, feather_name) do |*args, &block|
    add_feather(subclass.new(self, "#{@uid}:#{@feathers.size}", *args, &block))
  end
end

Instance Method Details

#feather_nameObject


67
68
69
# File 'app/helpers/backend/kujaku_helper.rb', line 67

def feather_name
  self.class.feather_name
end

#inspectObject


75
76
77
# File 'app/helpers/backend/kujaku_helper.rb', line 75

def inspect
  "<#{self.class.name}##{@uid}>"
end

#to_htmlObject

Raises:

  • (NotImplementedError)

71
72
73
# File 'app/helpers/backend/kujaku_helper.rb', line 71

def to_html
  raise NotImplementedError
end