Class: Trebuchet::Strategy::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/trebuchet/strategy/base.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#featureObject

Returns the value of attribute feature.



5
6
7
# File 'lib/trebuchet/strategy/base.rb', line 5

def feature
  @feature
end

Class Method Details

.strategy_nameObject



19
20
21
# File 'lib/trebuchet/strategy/base.rb', line 19

def self.strategy_name
  Trebuchet::Strategy.name_for_class(self)
end

Instance Method Details

#as_json(options = {}) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'lib/trebuchet/strategy/base.rb', line 23

def as_json(options = {})
  excluded = [:feature, :block]
  {:name => name}.tap do |h|
    instance_variables.map do |v|
      key = v.to_s.gsub('@','').to_sym
      h[key] = instance_variable_get(v) unless excluded.include?(key)
    end
  end
end

#export(options = nil) ⇒ Object



37
38
39
# File 'lib/trebuchet/strategy/base.rb', line 37

def export(options = nil)
  {:name => self.name, :options => options}
end

#feature_idObject



11
12
13
# File 'lib/trebuchet/strategy/base.rb', line 11

def feature_id
  feature.feature_id
end

#inspectObject



33
34
35
# File 'lib/trebuchet/strategy/base.rb', line 33

def inspect
  self.to_s
end

#nameObject



7
8
9
# File 'lib/trebuchet/strategy/base.rb', line 7

def name
  self.class.strategy_name
end

#needs_user?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/trebuchet/strategy/base.rb', line 15

def needs_user?
  true
end