Module: IfStatement::Features

Defined in:
lib/if_statement/features.rb

Instance Method Summary collapse

Instance Method Details

#feature(identifier, &block) ⇒ Object

executes &block if feature identifier is enabled



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/if_statement/features.rb', line 4

def feature identifier, &block
  if feature? identifier
    if respond_to? :with_output_buffer
      with_output_buffer &block
    else
      yield
    end
  end
  #"OH HAI"
  #yield if feature? identifier
end

#feature?(identifier) ⇒ Boolean

checks whether identifier is enabled in current env

Returns:

  • (Boolean)


17
18
19
20
21
22
23
24
# File 'lib/if_statement/features.rb', line 17

def feature? identifier
  value = IfStatement.read identifier
  if value.respond_to? :call
    !!instance_eval(&value)
  else
    value
  end
end